{"record":{"id":"d6706c721420ba42","repo":"Foundry376/Mailspring","slug":"failed-to-parse-mailsync-output-as-json","errorCode":null,"errorMessage":"Failed to parse mailsync output as JSON:","messagePattern":"Failed to parse mailsync output as JSON:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/mailsync-process.ts","lineNumber":432,"sourceCode":"\n    const onStreamCloseOrExit = (code: number, signal: string) => {\n      if (cleanedUp) {\n        return;\n      }\n\n      let error = null;\n      let lastJSON = null;\n      try {\n        if (outBuffer.length) {\n          // Skip debug output that starts with 'dbg::' prefix\n          if (outBuffer.startsWith('dbg::')) {\n            console.log('Skipping debug output from mailsync:', this._stripSecrets(outBuffer));\n          } else {\n            lastJSON = JSON.parse(outBuffer);\n          }\n        }\n      } catch (parseError) {\n        console.warn('Failed to parse mailsync output as JSON:', this._stripSecrets(outBuffer));\n      } finally {\n        if (lastJSON) {\n          if (lastJSON.error) {\n            error = new Error(this._stripSecrets(lastJSON.error));\n          } else {\n            this.emit('deltas', [outBuffer]);\n          }\n        }\n      }\n\n      if (errBuffer) {\n        error = new Error(this._stripSecrets(errBuffer));\n      }\n\n      cleanedUp = true;\n      this.emit('close', { code, error, signal } as MailsyncProcessExit);\n    };\n","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/mailsync-process.ts#L414-L450","documentation":"Warning in MailsyncProcess.onStreamCloseOrExit: the sync engine's buffered stdout could not be JSON.parse'd when the stream closed (and did not carry the 'dbg::' debug prefix). The raw buffer is logged with secrets stripped; lastJSON stays null, which downstream logic treats as 'no final result'. Usually caused by a partial line when the C++ process crashed mid-write.","triggerScenarios":"Thrown at app/src/mailsync-process.ts:432 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the logged raw buffer for a C++ crash message or stack trace preceding the JSON","Check mailsync crash logs / core dumps if this recurs — the process died before flushing a complete JSON line","Update or rebuild Mailspring-Sync if the output format changed"],"exampleFix":null,"handlingStrategy":"fallback","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"}