- Notifications
You must be signed in to change notification settings - Fork905
fix: add websocket close handling#17548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import{ typeApiErrorResponse, DetailedError } from "api/errors"; | ||
import { checkAuthorization } from "api/queries/authCheck"; | ||
import { | ||
templateByName, | ||
@@ -107,6 +107,15 @@ const CreateWorkspacePageExperimental: FC = () => { | ||
onError: (error) => { | ||
setWsError(error); | ||
}, | ||
onClose: () => { | ||
// There is no reason for the websocket to close while a user is on the page | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The assumption is that if the websocket closes while the component is mounted, that this is unexpected and we should inform the user with an error in the UI | ||
setWsError( | ||
new DetailedError( | ||
"Websocket connection for dynamic parameters unexpectedly closed.", | ||
"Refresh the page to reset the form.", | ||
), | ||
); | ||
}, | ||
}, | ||
); | ||
@@ -141,7 +150,7 @@ const CreateWorkspacePageExperimental: FC = () => { | ||
} = useExternalAuth(realizedVersionId); | ||
const isLoadingFormData = | ||
ws.current?.readyState=== WebSocket.CONNECTING || | ||
templateQuery.isLoading || | ||
permissionsQuery.isLoading; | ||
const loadFormDataError = templateQuery.error ?? permissionsQuery.error; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { DetailedError } from "api/errors"; | ||
import { chromatic } from "testHelpers/chromatic"; | ||
import { MockTemplate, MockUser } from "testHelpers/entities"; | ||
import { CreateWorkspacePageViewExperimental } from "./CreateWorkspacePageViewExperimental"; | ||
const meta: Meta<typeof CreateWorkspacePageViewExperimental> = { | ||
title: "Pages/CreateWorkspacePageViewExperimental", | ||
parameters: { chromatic }, | ||
component: CreateWorkspacePageViewExperimental, | ||
args: { | ||
autofillParameters: [], | ||
diagnostics: [], | ||
defaultName: "", | ||
defaultOwner: MockUser, | ||
externalAuth: [], | ||
externalAuthPollingState: "idle", | ||
hasAllRequiredExternalAuth: true, | ||
mode: "form", | ||
parameters: [], | ||
permissions: { | ||
createWorkspaceForAny: true, | ||
}, | ||
presets: [], | ||
sendMessage: () => {}, | ||
template: MockTemplate, | ||
}, | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof CreateWorkspacePageViewExperimental>; | ||
export const WebsocketError: Story = { | ||
args: { | ||
error: new DetailedError( | ||
"Websocket connection for dynamic parameters unexpectedly closed.", | ||
"Refresh the page to reset the form.", | ||
), | ||
}, | ||
}; |
Uh oh!
There was an error while loading.Please reload this page.