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

View File

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

View File

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