Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-46415: Revert "OCPBUGS-44920: save all window.windowErrors for easier debugging" #14624

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/@types/console/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare interface Window {
k8sMode: string;
capabilities: Record<string, string>[];
};
windowError?: string[];
windowError?: string;
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
i18n?: {}; // i18next instance, only available in development builds for debugging
store?: {}; // Redux store, only available in development builds for debugging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ declare interface Window {
SERVER_FLAGS: {
basePath: string;
};
windowError?: string[];
windowError?: string;
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
}
8 changes: 2 additions & 6 deletions frontend/packages/integration-tests-cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { a11yTestResults } from './a11y';
import './admin';

declare global {
interface Window {
windowError?: string[];
}

namespace Cypress {
interface Chainable {
visitAndWait(
Expand Down Expand Up @@ -86,8 +82,8 @@ after(() => {
});

export const checkErrors = () =>
cy.window().then(({ windowError }) => {
assert.isTrue(!windowError || windowError.length === 0, String(windowError));
cy.window().then((win) => {
assert.isTrue(!win.windowError, win.windowError);
});

export const testName = `test-${Math.random()
Expand Down
6 changes: 3 additions & 3 deletions frontend/public/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,18 +591,18 @@ graphQLReady.onReady(() => {
setInterval(() => store.dispatch(UIActions.updateTimestamps(Date.now())), 10000);

// Used by GUI tests to check for unhandled exceptions
window.windowError = [];
window.windowError = null;
window.onerror = (message, source, lineno, colno, error) => {
const formattedStack = error?.stack?.replace(/\\n/g, '\n');
const formattedMessage = `unhandled error: ${message} ${formattedStack || ''}`;
window.windowError.push(formattedMessage);
window.windowError = formattedMessage;
// eslint-disable-next-line no-console
console.error(formattedMessage, error || message);
};
window.onunhandledrejection = (promiseRejectionEvent) => {
const { reason } = promiseRejectionEvent;
const formattedMessage = `unhandled promise rejection: ${reason}`;
window.windowError.push(formattedMessage);
window.windowError = formattedMessage;
// eslint-disable-next-line no-console
console.error(formattedMessage, reason);
};
Expand Down
5 changes: 2 additions & 3 deletions frontend/public/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ export const init = () => {
},
saveMissing: true,
missingKeyHandler: function (lng, ns, key) {
const error = `Missing i18n key "${key}" in namespace "${ns}" and language "${lng}".`;
window.windowError = [...(window.windowError || []), error]; // OCPBUGS-45139: store all i18n errors for easy debugging
window.windowError = `Missing i18n key "${key}" in namespace "${ns}" and language "${lng}".`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of doing a full revert we can keep OCPBUGS-44920 fixed by appending new errors to the windowError string

// eslint-disable-next-line no-console
console.error(error);
console.error(window.windowError);
},
})
// Update loading promise and pass values and errors to the caller
Expand Down