{"record":{"id":"f7549b779133814e","repo":"Foundry376/Mailspring","slug":"you-registered-an-onbeforeunload-callback-that-d","errorCode":null,"errorMessage":"You registered an \"onBeforeUnload\" callback that does not return either exactly true or false. It returned ${returnValue}","messagePattern":"You registered an \"onBeforeUnload\" callback that does not return either exactly true or false\\. It returned (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/window-event-handler.ts","lineNumber":288,"sourceCode":"  }\n\n  runUnloadCallbacks() {\n    let hasReturned = false;\n\n    let unloadCallbacksRunning = 0;\n    const unloadCallbackComplete = () => {\n      unloadCallbacksRunning -= 1;\n      if (unloadCallbacksRunning === 0 && hasReturned) {\n        this.runUnloadFinished();\n      }\n    };\n\n    for (const callback of this.unloadCallbacks) {\n      const returnValue = callback(unloadCallbackComplete);\n      if (returnValue === false) {\n        unloadCallbacksRunning += 1;\n      } else if (returnValue !== true) {\n        console.warn(\n          `You registered an \"onBeforeUnload\" callback that does not return either exactly true or false. It returned ${returnValue}`,\n          callback\n        );\n      }\n    }\n\n    // In Electron, returning false cancels the close.\n    hasReturned = true;\n    if (unloadCallbacksRunning === 0) {\n      for (const callback of this.unloadCompleteCallbacks) {\n        callback();\n      }\n      return true;\n    }\n    return false;\n  }\n\n  runUnloadFinished() {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/window-event-handler.ts#L270-L306","documentation":"Warning in WindowEventHandler.runUnloadCallbacks: a callback registered via onBeforeUnload returned a value other than exactly true or false. Return values like undefined or a promise break the quit-flow protocol — the callback is skipped for completion tracking, so the window may quit before async work finishes.","triggerScenarios":"Thrown at app/src/window-event-handler.ts:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the callback to return true synchronously (done) or false (defer) per the onBeforeUnload contract","For async work, return false and invoke the provided completion callback when finished"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"648c685d602ece6bb00c22534b8734de6ac644b3","analyzedAt":"2026-09-03T02:00:24.311Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}