UI: Show "undefined" instead of -1 as pid in error popup when catching promise errors (#2555)

This commit is contained in:
catloversg
2026-03-08 02:34:04 +07:00
committed by GitHub
parent b6a29681f4
commit f8bb1ed997
3 changed files with 7 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ let currentId = 0;
export const DisplayError = (message: string, errorType: string, ws: WorkerScript | null = null) => { export const DisplayError = (message: string, errorType: string, ws: WorkerScript | null = null) => {
const scriptName = ws?.scriptRef?.filename ?? ""; const scriptName = ws?.scriptRef?.filename ?? "";
const hostname = ws?.hostname ?? ""; const hostname = ws?.hostname ?? "";
const pid = ws?.pid ?? -1; const pid = ws?.pid;
const parsedMessage = ws ? parseBlobUrlInMessage(ws, message) : message; const parsedMessage = ws ? parseBlobUrlInMessage(ws, message) : message;
const errorPageOpen = Router.page() === SimplePage.RecentErrors; const errorPageOpen = Router.page() === SimplePage.RecentErrors;
if (!errorPageOpen) { if (!errorPageOpen) {
@@ -19,7 +19,7 @@ export const DisplayError = (message: string, errorType: string, ws: WorkerScrip
if (prior) { if (prior) {
prior.occurrences++; prior.occurrences++;
prior.time = new Date(); prior.time = new Date();
if (pid !== -1) { if (pid !== undefined) {
prior.pid = pid; prior.pid = pid;
} }
prior.server = hostname; prior.server = hostname;
@@ -37,6 +37,7 @@ export const DisplayError = (message: string, errorType: string, ws: WorkerScrip
occurrences: 1, occurrences: 1,
time: new Date(), time: new Date(),
unread: !errorPageOpen, unread: !errorPageOpen,
force: false,
}); });
while (ErrorState.Errors.length > 100) { while (ErrorState.Errors.length > 100) {
ErrorState.Errors.pop(); ErrorState.Errors.pop();

View File

@@ -73,7 +73,7 @@ export function ErrorModal(): React.ReactElement {
<p> <p>
Script: {error.scriptName} Script: {error.scriptName}
<br /> <br />
PID: {error.pid} PID: {String(error.pid)}
</p> </p>
{!Settings.SuppressErrorModals && ( {!Settings.SuppressErrorModals && (
<OptionSwitch <OptionSwitch
@@ -92,7 +92,7 @@ export function ErrorModal(): React.ReactElement {
<Box className={classes.inlineFlexBox}> <Box className={classes.inlineFlexBox}>
<Button onClick={() => onClose()}>Close</Button> <Button onClick={() => onClose()}>Close</Button>
<div> <div>
<Button disabled={error.pid === -1} onClick={viewLogs}> <Button disabled={error.pid === undefined} onClick={viewLogs}>
View Script Logs View Script Logs
</Button> </Button>
<Button onClick={goToErrorPage}>Errors Page</Button> <Button onClick={goToErrorPage}>Errors Page</Button>

View File

@@ -6,11 +6,11 @@ export type ErrorRecord = {
errorType: string; errorType: string;
message: string; message: string;
scriptName: string; scriptName: string;
pid: number; pid?: number;
occurrences: number; occurrences: number;
time: Date; time: Date;
unread: boolean; unread: boolean;
force?: boolean; force: boolean;
}; };
export const ErrorState = { export const ErrorState = {