Skip to content

Commit

Permalink
Rework "Backend is not available" error page (#930)
Browse files Browse the repository at this point in the history
* feat: remove che-workspace-client lib

Signed-off-by: Oleksii Orel <oorel@redhat.com>

* fix: 'Backend is not available...' error message

Signed-off-by: Oleksii Orel <oorel@redhat.com>
---------

Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 authored Oct 6, 2023
1 parent 1002797 commit b1b21bd
Show file tree
Hide file tree
Showing 94 changed files with 1,630 additions and 584 deletions.
37 changes: 21 additions & 16 deletions .deps/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@
| [`@istanbuljs/schema@0.1.3`](git+https://github.com/istanbuljs/schema.git) | MIT | clearlydefined |
| [`@jest/console@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/core@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/environment@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/environment@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`@jest/expect-utils@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/expect@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/fake-timers@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/fake-timers@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`@jest/globals@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/reporters@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/schemas@29.6.0`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/source-map@29.6.0`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/test-result@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/test-sequencer@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/test-sequencer@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`@jest/transform@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/types@29.6.1`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`@jest/types@29.6.3`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`@jridgewell/gen-mapping@0.3.3`](https://github.com/jridgewell/gen-mapping) | MIT | clearlydefined |
| [`@jridgewell/resolve-uri@3.1.1`](https://github.com/jridgewell/resolve-uri) | MIT | clearlydefined |
| [`@jridgewell/set-array@1.1.2`](https://github.com/jridgewell/set-array) | MIT | clearlydefined |
Expand Down Expand Up @@ -138,7 +138,7 @@
| [`@sinonjs/commons@3.0.0`](git+https://github.com/sinonjs/commons.git) | BSD-3-Clause | clearlydefined |
| [`@sinonjs/fake-timers@10.3.0`](https://github.com/sinonjs/fake-timers.git) | BSD-3-Clause | #9214 |
| [`@testing-library/dom@7.31.2`](https://github.com/testing-library/dom-testing-library) | MIT | (clearlydefined)[https://clearlydefined.io/definitions/npm/npmjs/@testing-library/dom/7.31.2] |
| [`@testing-library/jest-dom@5.17.0`](https://github.com/testing-library/jest-dom) | MIT | clearlydefined |
| [`@testing-library/jest-dom@6.1.3`](https://github.com/testing-library/jest-dom) | MIT | clearlydefined |
| [`@testing-library/react@10.4.9`](https://github.com/testing-library/react-testing-library) | MIT | clearlydefined |
| [`@testing-library/user-event@12.8.3`](https://github.com/testing-library/user-event) | MIT | clearlydefined |
| [`@tootallnate/once@2.0.0`](git://github.com/TooTallNate/once.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -253,11 +253,12 @@
| [`at-least-node@1.0.0`](git+https://github.com/RyanZim/at-least-node.git) | ISC | clearlydefined |
| [`available-typed-arrays@1.0.5`](git+https://github.com/inspect-js/available-typed-arrays.git) | MIT | clearlydefined |
| [`axios-mock-adapter@1.21.5`](git+https://github.com/ctimmerm/axios-mock-adapter.git) | MIT | clearlydefined |
| [`babel-jest@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`axios@1.4.0`](https://github.com/axios/axios.git) | MIT | clearlydefined |
| [`babel-jest@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`babel-plugin-istanbul@6.1.1`](git+https://github.com/istanbuljs/babel-plugin-istanbul.git) | BSD-3-Clause | clearlydefined |
| [`babel-plugin-jest-hoist@29.5.0`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`babel-plugin-jest-hoist@29.6.3`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`babel-preset-current-node-syntax@1.0.1`](https://github.com/nicolo-ribaudo/babel-preset-current-node-syntax.git) | MIT | clearlydefined |
| [`babel-preset-jest@29.5.0`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`babel-preset-jest@29.6.3`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`before-after-hook@2.2.3`](https://github.com/gr2m/before-after-hook.git) | Apache-2.0 | clearlydefined |
| [`big-integer@1.6.51`](git@github.com:peterolson/BigInteger.js.git) | Unlicense | #2439 |
| [`big.js@5.2.2`](https://github.com/MikeMcl/big.js.git) | MIT | clearlydefined |
Expand All @@ -279,7 +280,7 @@
| [`callsites@3.1.0`](https://github.com/sindresorhus/callsites.git) | MIT | clearlydefined |
| [`camel-case@4.1.2`](git://github.com/blakeembrey/change-case.git) | MIT | clearlydefined |
| [`camelcase-keys@6.2.2`](https://github.com/sindresorhus/camelcase-keys.git) | MIT | clearlydefined |
| [`camelcase@5.3.1`](https://github.com/sindresorhus/camelcase.git) | MIT | clearlydefined |
| [`camelcase@6.3.0`](https://github.com/sindresorhus/camelcase.git) | MIT | clearlydefined |
| [`caniuse-api@3.0.0`](https://github.com/nyalab/caniuse-api.git) | MIT | clearlydefined |
| [`caniuse-lite@1.0.30001521`](https://github.com/browserslist/caniuse-lite.git) | CC-BY-4.0 | #1196 |
| [`chalk@4.1.2`](https://github.com/chalk/chalk.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -324,6 +325,7 @@
| [`copy-webpack-plugin@11.0.0`](https://github.com/webpack-contrib/copy-webpack-plugin.git) | MIT | clearlydefined |
| [`core-js-pure@3.32.0`](https://github.com/zloirock/core-js.git) | MIT | #9880 |
| [`cosmiconfig@7.0.0`](git+https://github.com/davidtheclark/cosmiconfig.git) | MIT | clearlydefined |
| [`create-jest@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`cross-spawn@7.0.3`](git@github.com:moxystudio/node-cross-spawn.git) | MIT | clearlydefined |
| [`crypto-random-string@2.0.0`](https://github.com/sindresorhus/crypto-random-string.git) | MIT | clearlydefined |
| [`css-declaration-sorter@6.4.1`](https://github.com/Siilwyn/css-declaration-sorter.git) | ISC | #9434 |
Expand Down Expand Up @@ -559,34 +561,35 @@
| [`jackspeak@2.3.0`](git+https://github.com/isaacs/jackspeak.git) | BlueOak-1.0.0 | transitive dependency |
| [`jake@10.8.7`](git://github.com/jakejs/jake.git) | Apache-2.0 | #1316 |
| [`jest-changed-files@29.5.0`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-circus@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-circus@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`jest-cli@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-config@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-config@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`jest-diff@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-docblock@29.4.3`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-each@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-environment-jsdom@29.6.2`](https://github.com/facebook/jest.git) | MIT | #9317 |
| [`jest-each@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`jest-environment-jsdom@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`jest-environment-node@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-get-type@29.4.3`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-haste-map@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-leak-detector@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-matcher-utils@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-message-util@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-mock@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-mock@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`jest-pnp-resolver@1.2.3`](https://github.com/arcanis/jest-pnp-resolver.git) | MIT | clearlydefined |
| [`jest-regex-util@29.4.3`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-resolve-dependencies@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-resolve@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-runner@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-runtime@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-snapshot@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-util@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-util@29.7.0`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
| [`jest-validate@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-watcher@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest-websocket-mock@2.4.1`](git+https://github.com/romgain/jest-websocket-mock.git) | MIT | clearlydefined |
| [`jest-worker@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jest@29.6.2`](https://github.com/facebook/jest.git) | MIT | clearlydefined |
| [`jsdom@20.0.3`](https://github.com/jsdom/jsdom.git) | MIT | #7436 |
| [`jsesc@2.5.2`](https://github.com/mathiasbynens/jsesc.git) | MIT | clearlydefined |
| [`json-parse-better-errors@1.0.2`](https://github.com/zkat/json-parse-better-errors) | MIT | clearlydefined |
| [`json-parse-even-better-errors@3.0.0`](https://github.com/npm/json-parse-even-better-errors.git) | MIT | clearlydefined |
| [`json-stable-stringify-without-jsonify@1.0.1`](git://github.com/samn/json-stable-stringify.git) | MIT | clearlydefined |
Expand All @@ -600,6 +603,7 @@
| [`kleur@3.0.3`](https://github.com/lukeed/kleur.git) | MIT | clearlydefined |
| [`known-css-properties@0.27.0`](https://github.com/known-css/known-css-properties.git) | MIT | clearlydefined |
| [`lerna@6.6.2`](git+https://github.com/lerna/lerna.git) | MIT | #7595 |
| [`leven@3.1.0`](https://github.com/sindresorhus/leven.git) | MIT | clearlydefined |
| [`levn@0.4.1`](git://github.com/gkz/levn.git) | MIT | clearlydefined |
| [`libnpmaccess@6.0.4`](https://github.com/npm/cli.git) | ISC | clearlydefined |
| [`libnpmpublish@7.1.4`](https://github.com/npm/cli.git) | ISC | clearlydefined |
Expand Down Expand Up @@ -841,7 +845,7 @@
| [`string.prototype.trimstart@1.0.6`](git://github.com/es-shims/String.prototype.trimStart.git) | MIT | #4647 |
| [`strip-ansi-cjs@6.0.1`](https://github.com/chalk/strip-ansi.git) | MIT | transitive dependency |
| [`strip-ansi@6.0.1`](https://github.com/chalk/strip-ansi.git) | MIT | clearlydefined |
| [`strip-bom@3.0.0`](https://github.com/sindresorhus/strip-bom.git) | MIT | clearlydefined |
| [`strip-bom@4.0.0`](https://github.com/sindresorhus/strip-bom.git) | MIT | clearlydefined |
| [`strip-final-newline@2.0.0`](https://github.com/sindresorhus/strip-final-newline.git) | MIT | clearlydefined |
| [`strip-indent@3.0.0`](https://github.com/sindresorhus/strip-indent.git) | MIT | clearlydefined |
| [`strip-json-comments@3.1.1`](https://github.com/sindresorhus/strip-json-comments.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -875,6 +879,7 @@
| [`through2@4.0.2`](https://github.com/rvagg/through2.git) | MIT | clearlydefined |
| [`through@2.3.8`](https://github.com/dominictarr/through.git) | MIT | #1036 |
| [`titleize@3.0.0`](https://github.com/sindresorhus/titleize.git) | MIT | clearlydefined |
| [`to-fast-properties@2.0.0`](https://github.com/sindresorhus/to-fast-properties.git) | MIT | clearlydefined |
| [`to-regex-range@5.0.1`](https://github.com/micromatch/to-regex-range.git) | MIT | clearlydefined |
| [`totalist@1.1.0`](https://github.com/lukeed/totalist.git) | MIT | clearlydefined |
| [`touch@3.1.0`](git://github.com/isaacs/node-touch.git) | ISC | clearlydefined |
Expand Down
2 changes: 0 additions & 2 deletions .deps/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
| [`@eclipse-che/dashboard-backend@7.75.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-frontend@7.75.0-next`](git://github.com/eclipse/che-dashboard.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/devfile-converter@0.0.1-ff55f9a`](git+https://github.com/che-incubator/devfile-converter.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/workspace-client@0.0.1-1672830275`](https://github.com/eclipse/che-workspace-client) | EPL-2.0 | ecd.che |
| [`@fastify/accept-negotiator@1.1.0`](git+https://github.com/fastify/accept-negotiator.git) | MIT | clearlydefined |
| [`@fastify/ajv-compiler@3.5.0`](git+https://github.com/fastify/ajv-compiler.git) | MIT | clearlydefined |
| [`@fastify/cookie@8.3.0`](git+ssh://git@github.com/fastify/fastify-cookie.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -379,7 +378,6 @@
| [`trim-right@1.0.1`](https://github.com/sindresorhus/trim-right.git) | MIT | clearlydefined |
| [`tslib@2.6.1`](https://github.com/Microsoft/tslib.git) | 0BSD | #9189 |
| [`tunnel-agent@0.6.0`](https://github.com/mikeal/tunnel-agent) | Apache-2.0 | clearlydefined |
| [`tunnel@0.0.6`](https://github.com/koichik/node-tunnel.git) | MIT | clearlydefined |
| [`tweetnacl@0.14.5`](https://github.com/dchest/tweetnacl-js.git) | Unlicense | #1035 |
| [`type-fest@1.4.0`](https://github.com/sindresorhus/type-fest.git) | (MIT OR CC0-1.0) | clearlydefined |
| [`underscore@1.13.6`](git://github.com/jashkenas/underscore.git) | MIT | clearlydefined |
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.2",
"jest": "^29.7.0",
"prettier": "^3.0.1",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
Expand Down
21 changes: 21 additions & 0 deletions packages/common/src/helpers/__tests__/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,5 +335,26 @@ describe('Errors helper', () => {
};
expect(getMessage(error)).toEqual(expectedMessage);
});

it('should return a message if `error.response.data` includes a HTML page', () => {
const htmlPage =
'<!DOCTYPE html><html><head></head><body>...</body></html>';
const error = {
name: 'Error',
config: {},
request: {},
response: {
data: htmlPage,
status: 500,
statusText: 'Internal Server Error',
headers: {},
config: {},
request: {},
},
message: '"500" returned by "/kubernetes/namespace/provision".',
};

expect(getMessage(error)).toEqual(error.message);
});
});
});
4 changes: 3 additions & 1 deletion packages/common/src/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export function getMessage(error: unknown): string {
if (includesAxiosResponse(error)) {
const response = error.response;
if (typeof response.data === 'string') {
return response.data;
if (response.data.toLowerCase().trim().indexOf('<!doctype') !== 0) {
return response.data;
}
} else if (response.data.message) {
return response.data.message;
} else if (response.config.url) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"eslint-plugin-prettier": "^5.0.0",
"eslint-webpack-plugin": "^4.0.1",
"file-loader": "^6.2.0",
"jest": "^29.6.2",
"jest": "^29.7.0",
"json-schema": "^0.4.0",
"nodemon": "^3.0.1",
"prettier": "^3.0.2",
Expand Down
7 changes: 3 additions & 4 deletions packages/dashboard-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
},
"dependencies": {
"@eclipse-che/devfile-converter": "0.0.1-ff55f9a",
"@eclipse-che/workspace-client": "0.0.1-1672830275",
"@patternfly/react-core": "^4.276.11",
"@patternfly/react-icons": "^4.93.7",
"@patternfly/react-table": "^4.113.3",
Expand Down Expand Up @@ -80,7 +79,7 @@
"@kubernetes/client-node": "^0.18.1",
"@react-mock/state": "^0.1.8",
"@testing-library/dom": "^7.30.3",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^10.3.0",
"@testing-library/user-event": "^12.1",
"@types/axios": "^0.14.0",
Expand Down Expand Up @@ -113,8 +112,8 @@
"hard-source-webpack-plugin": "^0.13.1",
"html-webpack-plugin": "^5.5.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.6.4",
"jest-websocket-mock": "^2.4.1",
"loader-utils": "^3.2.1",
"mini-css-extract-plugin": "^2.7.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export class NoResourceComponent extends React.Component {
// mute the outputs
console.error = jest.fn();

const mockOnError = jest.fn();
function wrapComponent(componentToWrap: React.ReactNode) {
return <ErrorBoundary>{componentToWrap}</ErrorBoundary>;
return <ErrorBoundary onError={mockOnError}>{componentToWrap}</ErrorBoundary>;
}

describe('Error boundary', () => {
Expand Down Expand Up @@ -66,6 +67,7 @@ describe('Error boundary', () => {
const showDetailsAction = screen.getByRole('button', { name: 'View stack' });
userEvent.click(showDetailsAction);

expect(mockOnError).not.toHaveBeenCalled();
expect(screen.queryByText('in BadComponent', { exact: false })).toBeTruthy();
expect(screen.queryByText('in ErrorBoundary', { exact: false })).toBeTruthy();

Expand Down Expand Up @@ -98,6 +100,7 @@ describe('Error boundary', () => {
const errorBoundary = wrapComponent(<NoResourceComponent />);
render(errorBoundary);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(
screen.queryByText('The application has been likely updated on the server.', {
exact: false,
Expand All @@ -111,6 +114,7 @@ describe('Error boundary', () => {
const errorBoundary = wrapComponent(<NoResourceComponent />);
render(errorBoundary);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(
screen.queryByText('Refreshing a page to get newer resources in', { exact: false }),
).toBeTruthy();
Expand All @@ -127,6 +131,7 @@ describe('Error boundary', () => {
const stopCountdownAction = screen.getByRole('button', { name: 'Stop countdown' });
userEvent.click(stopCountdownAction);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(
screen.queryByText('Refreshing a page to get newer resources in', { exact: false }),
).toBeFalsy();
Expand All @@ -148,6 +153,7 @@ describe('Error boundary', () => {

jest.advanceTimersByTime(35000);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(window.location.reload).toHaveBeenCalled();
expect(window.location.reload).toHaveBeenCalledTimes(1);
});
Expand All @@ -161,6 +167,7 @@ describe('Error boundary', () => {
userEvent.click(reloadNowAction);
userEvent.click(reloadNowAction);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(window.location.reload).toHaveBeenCalled();
expect(window.location.reload).toHaveBeenCalledTimes(3);
});
Expand All @@ -185,6 +192,7 @@ describe('Error boundary', () => {
window.dispatchEvent(new Event('beforeunload'));
render(errorBoundary);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(
screen.queryByText(
'Contact an administrator if refreshing continues after the next load.',
Expand Down Expand Up @@ -225,6 +233,7 @@ describe('Error boundary', () => {
window.dispatchEvent(new Event('beforeunload'));
render(goodComponent);

expect(mockOnError).toHaveBeenCalledWith('Loading chunk 23 failed.');
expect(sessionStorage.getItem(STORAGE_KEY_RELOAD_NUMBER)).toBeNull();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const STORAGE_KEY_RELOAD_NUMBER = 'UD:ErrorBoundary:reloaded';
const RELOAD_TIMEOUT_SEC = 30;
const RELOADS_FOR_EXTENDED_MESSAGE = 2;

type Props = PropsWithChildren;
type Props = PropsWithChildren & {
onError: (error?: string) => void;
};
type State = {
hasError: boolean;
error?: Error;
Expand Down Expand Up @@ -74,6 +76,7 @@ export class ErrorBoundary extends React.PureComponent<Props, State> {
});

if (this.testResourceNotFound(error)) {
this.props.onError(error.message);
this.setState({
shouldReload: true,
});
Expand Down
Loading

0 comments on commit b1b21bd

Please sign in to comment.