Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

PRD-7394 Attach the crash dump that armed the report (#5791)

Andrew Mikofalvy7db5dae8ec64
diff --git a/.changeset/crash-report-bound-dump.md b/.changeset/crash-report-bound-dump.md
new file mode 100644
index 000000000..612ccbd4d
--- /dev/null
+++ b/.changeset/crash-report-bound-dump.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Crash reports now attach only the crash dump from the crash that prompted them. If that dump can't be added, the report says so instead of attaching a different one.
diff --git a/docs/content/reference/what-open-knowledge-writes.mdx b/docs/content/reference/what-open-knowledge-writes.mdx
index 27908300f..1b418f67c 100644
--- a/docs/content/reference/what-open-knowledge-writes.mdx
+++ b/docs/content/reference/what-open-knowledge-writes.mdx
@@ -404,7 +404,7 @@ None of your content, by default. Everything above is written to your own disk.
| What | When | Where it goes |
| --- | --- | --- |
| Diagnostic bundle | Only when you run `ok diagnose bundle` (you can inspect it first). On macOS it also carries the crash reports the OS recorded for this app and its helper processes (listed above), which are machine-wide rather than project-scoped; only this app's are collected, never another application's, though a report of ours still names the processes it was running alongside, and the summary printed before the zip is written says what that search found even when the answer is nothing | Wherever you send it |
-| In-app bug report | Only when you click **Send** in the desktop app's **Help → Report a bug…** dialog, or the `Cmd+Shift+D` / `Ctrl+Shift+D` shortcut that opens the same dialog — it builds a secret-redacted zip you can reveal and inspect first, and nothing is sent without that explicit click. The zip carries a picture of the app window unless you uncheck **Screenshot** in that dialog, and the preview there is the picture that would be sent. You can also attach up to three images by dropping them on the **What happened?** box, pasting them anywhere in the dialog (`Cmd+V` / `Ctrl+V`), or browsing with the paperclip in that box. Neither these images nor the screenshot are scanned or redacted, so review them before sending. A report started from an agent chat's **Report a problem with this chat…** also carries, unless you uncheck **This conversation**, the newest 4 MB of that chat's messages, tool calls, and their output, and the chat's metadata file, which names the chat's title, the project folder's path, the document the chat started from, and the agent and its settings. Known secrets are scrubbed from both. Images and other binary content in the chat, including images pasted into a message, are replaced by a note of their type and size, while text files attached to a message are included and scrubbed the same way. If the chat's messages can't be added, the review step says so and the report goes without the conversation. If only the metadata file can't be read, the report carries the messages without it, and the review step doesn't say so. A report reached through a surface you opened only to get to the reporter — the command palette, the Help popover, the Windows and Linux menu bar, or an agent chat's **Settings** menu — waits for that surface to close first, and carries no marker, because the row it would point at has already gone. Every other report you start yourself photographs the screen as it is, so an open menu or another person's document visible at the time is in the picture, and carries a marker drawn where your pointer was, since a screenshot never includes the cursor. No marker is drawn either if the pointer has not moved since the window loaded, or has since left the window. The invitation that appears on its own after a crash is the exception to all of this: it carries no picture at all. After a crash, the same dialog adds an **off-by-default** "Include crash dump" checkbox: a crash dump is a memory snapshot that can contain document content and can't be redacted, and it is only ever attached when you check that box. On macOS the zip also carries the update helper's install log (listed above), which is machine-wide rather than project-scoped; the zip's own README names it and says where it came from. At the **Detailed diagnostics** level — pre-checked on the invitation that follows a crash — it additionally carries the crash reports macOS itself recorded for this app and its helpers (also listed above), which are machine-wide for the same reason and named in the same README; only this app's are collected, never another application's, though a report of ours still names the processes it was running alongside, and the zip always says what that search found even when the answer is nothing. The zip also carries a short send history of the bug reports previously generated on this machine — when each was generated and whether sending it succeeded — which is what makes a report that failed to send diagnosable at all. That history is machine-wide too, so it names the other projects you have filed reports from; it carries no document content, and the README names it the same way | Send uploads the zip to the bug-report intake: `openknowledge.ai` unless [`OK_BUG_REPORT_INTAKE_URL`](./configuration.mdx#environment-variables) points elsewhere. If the upload fails, Send falls back to a prefilled email draft to [email protected] that you send yourself, naming the zip to attach |
+| In-app bug report | Only when you click **Send** in the desktop app's **Help → Report a bug…** dialog, or the `Cmd+Shift+D` / `Ctrl+Shift+D` shortcut that opens the same dialog — it builds a secret-redacted zip you can reveal and inspect first, and nothing is sent without that explicit click. The zip carries a picture of the app window unless you uncheck **Screenshot** in that dialog, and the preview there is the picture that would be sent. You can also attach up to three images by dropping them on the **What happened?** box, pasting them anywhere in the dialog (`Cmd+V` / `Ctrl+V`), or browsing with the paperclip in that box. Neither these images nor the screenshot are scanned or redacted, so review them before sending. A report started from an agent chat's **Report a problem with this chat…** also carries, unless you uncheck **This conversation**, the newest 4 MB of that chat's messages, tool calls, and their output, and the chat's metadata file, which names the chat's title, the project folder's path, the document the chat started from, and the agent and its settings. Known secrets are scrubbed from both. Images and other binary content in the chat, including images pasted into a message, are replaced by a note of their type and size, while text files attached to a message are included and scrubbed the same way. If the chat's messages can't be added, the review step says so and the report goes without the conversation. If only the metadata file can't be read, the report carries the messages without it, and the review step doesn't say so. A report reached through a surface you opened only to get to the reporter — the command palette, the Help popover, the Windows and Linux menu bar, or an agent chat's **Settings** menu — waits for that surface to close first, and carries no marker, because the row it would point at has already gone. Every other report you start yourself photographs the screen as it is, so an open menu or another person's document visible at the time is in the picture, and carries a marker drawn where your pointer was, since a screenshot never includes the cursor. No marker is drawn either if the pointer has not moved since the window loaded, or has since left the window. The invitation that appears on its own after a crash is the exception to all of this: it carries no picture at all. When the app holds a crash dump, the same dialog adds a **Crash dump** checkbox. It starts checked on the invitation that follows a crash with a dump available, and unchecked on a report you open yourself. A crash dump is a memory snapshot that can contain document content and can't be redacted, so it is attached only if that box is checked when you create the report, and you review the result before anything is sent. The invitation attaches the dump of the crash it was raised for, never a newer one; if that dump can't be added, the review step says so and the report goes without it. On macOS the zip also carries the update helper's install log (listed above), which is machine-wide rather than project-scoped; the zip's own README names it and says where it came from. At the **Detailed diagnostics** level — pre-checked on the invitation that follows a crash — it additionally carries the crash reports macOS itself recorded for this app and its helpers (also listed above), which are machine-wide for the same reason and named in the same README; only this app's are collected, never another application's, though a report of ours still names the processes it was running alongside, and the zip always says what that search found even when the answer is nothing. The zip also carries a short send history of the bug reports previously generated on this machine — when each was generated and whether sending it succeeded — which is what makes a report that failed to send diagnosable at all. That history is machine-wide too, so it names the other projects you have filed reports from; it carries no document content, and the README names it the same way | Send uploads the zip to the bug-report intake: `openknowledge.ai` unless [`OK_BUG_REPORT_INTAKE_URL`](./configuration.mdx#environment-variables) points elsewhere. If the upload fails, Send falls back to a prefilled email draft to [email protected] that you send yourself, naming the zip to attach |
| Uninstall feedback | Only if you answer the optional "Before you go" screen or prompt. The macOS desktop asks after you confirm removal, before the app quits and cleanup starts; feedback can be sent even if cleanup later fails. Interactive `ok uninstall` asks only after successful cleanup. Skipping sends nothing; CLI runs with `--yes`, `--json`, or non-interactive input never ask | `openknowledge.ai/api/feedback` — the reason you picked, your note, your email address if you gave one, plus the app version and platform. It files one ticket for the team; nothing from your notes is included |
| Feedback form | Only when you click **Send** in the feedback form, opened from **Help → Send feedback**, the command palette's **Send feedback** command, or the feedback card in the sidebar. Images you drop on, paste into, or attach to the message box go with it; like bug report images, they are not scanned or redacted | `openknowledge.ai/api/feedback` — your rating, the reasons you picked, your note, your email address if you gave one, up to three attached images, plus the app version and platform. In the desktop app the images upload first to the bug-report intake (`openknowledge.ai` unless [`OK_BUG_REPORT_INTAKE_URL`](./configuration.mdx#environment-variables) points elsewhere) and the feedback carries links to them. If an image upload fails, the images go inline with the feedback to `openknowledge.ai/api/feedback` instead |
| Semantic search embeddings | Only when you enable [semantic search](./configuration.mdx#semantic-search) **and** set a key — off by default | Your configured embeddings provider (OpenAI by default) |
diff --git a/packages/app/src/components/ReportBugDialog.dom.test.tsx b/packages/app/src/components/ReportBugDialog.dom.test.tsx
index 6a478d5ad..29284a376 100644
--- a/packages/app/src/components/ReportBugDialog.dom.test.tsx
+++ b/packages/app/src/components/ReportBugDialog.dom.test.tsx
@@ -76,6 +76,7 @@ type CreateRequest = {
includeScreenshot?: boolean;
attachments?: { contentType: string; bytes: Uint8Array }[];
agentChatThreadId?: string;
+ crashEventId?: string;
};
type SendRequest = OkBugReportSendInput;
@@ -652,6 +653,7 @@ describe('ReportBugDialog', () => {
level: 'full',
note: 'Crash source: previous session ended without a clean quit\nCrash event: boot:1751871600000',
includeCrashDump: true,
+ crashEventId: 'boot:1751871600000',
},
]);
});
@@ -766,6 +768,37 @@ describe('ReportBugDialog', () => {
expect(screen.queryByText("The conversation couldn't be added to this report.")).toBeNull();
});
+ test('the review step says so when the crash dump could not be added', async () => {
+ installBridge();
+ await renderDialog({ crashInvite: BOOT_INVITE });
+ await createReport();
+
+ expect(screen.getByText("The crash dump couldn't be added to this report.")).not.toBeNull();
+ });
+
+ test('a crash dump that made it into the report is not reported as missing', async () => {
+ installBridge({
+ create: () =>
+ Promise.resolve({
+ ...CREATE_OK,
+ summary: { ...SUMMARY, files: [...SUMMARY.files, 'extra/renderer.dmp'] },
+ }),
+ });
+ await renderDialog({ crashInvite: BOOT_INVITE });
+ await createReport();
+
+ expect(screen.queryByText("The crash dump couldn't be added to this report.")).toBeNull();
+ });
+
+ test('an unchecked crash dump is not reported as missing from the review', async () => {
+ installBridge();
+ await renderDialog({ crashInvite: BOOT_INVITE });
+ await userEvent.click(screen.getByRole('checkbox', { name: 'Crash dump' }));
+ await createReport();
+
+ expect(screen.queryByText("The crash dump couldn't be added to this report.")).toBeNull();
+ });
+
test('unchecking Crash dump excludes the minidump from create', async () => {
const log = installBridge();
await renderDialog({ crashInvite: BOOT_INVITE });
@@ -795,6 +828,7 @@ describe('ReportBugDialog', () => {
await screen.findByRole('heading', { name: 'Review your report' });
expect(log.createCalls[0]).not.toHaveProperty('includeCrashDump');
+ expect(log.createCalls[0]).not.toHaveProperty('crashEventId');
});
test('a crash invite that names the crashed version folds it in last', async () => {
@@ -809,6 +843,7 @@ describe('ReportBugDialog', () => {
level: 'full',
note: 'Crash source: previous session ended without a clean quit\nCrash event: boot:1751871600000\nCrashed app version: 0.41.0',
includeCrashDump: true,
+ crashEventId: 'boot:1751871600000',
},
]);
});
@@ -869,6 +904,7 @@ describe('ReportBugDialog', () => {
await userEvent.click(dumpBox);
await createReport();
expect(log.createCalls[0]?.includeCrashDump).toBe(true);
+ expect(log.createCalls[0]).not.toHaveProperty('crashEventId');
});
test('a manually-opened report left untouched declines the dump rather than omitting the flag', async () => {
diff --git a/packages/app/src/components/ReportBugDialogBody.tsx b/packages/app/src/components/ReportBugDialogBody.tsx
index 50ba63a1d..3542a8545 100644
--- a/packages/app/src/components/ReportBugDialogBody.tsx
+++ b/packages/app/src/components/ReportBugDialogBody.tsx
@@ -121,7 +121,12 @@ function crashInviteLines(invite: OkBugReportCrashDetectedEvent): string[] {
type Phase =
| { step: 'compose'; creating: boolean; createError: string | null }
- | { step: 'review'; report: CreatedReport; conversationMissing: boolean };
+ | {
+ step: 'review';
+ report: CreatedReport;
+ conversationMissing: boolean;
+ crashDumpMissing: boolean;
+ };
const COMPOSE_IDLE: Phase = { step: 'compose', creating: false, createError: null };
@@ -245,10 +250,14 @@ function ReportBugDialog({
const attachmentInputs = await toAttachmentInputs(attachments);
if (opSeqRef.current !== seq) return;
const conversationRequested = agentChat !== undefined && includeChat;
+ const crashDumpRequested = crashDumpAvailable && includeDump;
const result = await bugReport.create({
level: detailed ? 'full' : 'standard',
note: composeNote(note, noteContextLines),
...(crashDumpAvailable ? { includeCrashDump: includeDump } : {}),
+ ...(crashDumpAvailable && crashInvite !== undefined
+ ? { crashEventId: crashInvite.eventId }
+ : {}),
...(screenshot !== null ? { includeScreenshot } : {}),
...(attachmentInputs.length > 0 ? { attachments: attachmentInputs } : {}),
...(conversationRequested ? { agentChatThreadId: agentChat.threadId } : {}),
@@ -265,6 +274,8 @@ function ReportBugDialog({
},
conversationMissing:
conversationRequested && !result.summary.files.some(isBugReportAgentChatEntry),
+ crashDumpMissing:
+ crashDumpRequested && !result.summary.files.some(isBugReportCrashDumpEntry),
});
} else {
setPhase({ step: 'compose', creating: false, createError: result.error });
@@ -685,6 +696,11 @@ function ReportBugDialog({
<Trans>The conversation couldn't be added to this report.</Trans>
</p>
) : null}
+ {phase.crashDumpMissing ? (
+ <p className="text-xs text-muted-foreground">
+ <Trans>The crash dump couldn't be added to this report.</Trans>
+ </p>
+ ) : null}
<div className="flex items-start gap-2 rounded-md border bg-muted/50 px-3 py-2.5 text-xs text-muted-foreground">
<ShieldIcon
className="size-3.5 shrink-0 text-muted-foreground"
diff --git a/packages/app/src/locales/ar/messages.json b/packages/app/src/locales/ar/messages.json
index 5d5f4a30c..a33c6a65e 100644
--- a/packages/app/src/locales/ar/messages.json
+++ b/packages/app/src/locales/ar/messages.json
@@ -287,6 +287,7 @@
"1ouiTz": ["الصورة ", ["identity"], " مستبعدة. انتقل إلى المرجع."],
"1pdLQw": ["الصورة غير موجودة"],
"1qpGKz": ["تعذّر حفظ التغييرات. حاول تعديل لون مرة أخرى."],
+ "1rsUiG": ["تعذّرت إضافة تفريغ الأعطال إلى هذا التقرير."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["رفض"],
"1u-mAI": ["تعذّر بدء المزامنة. تحقق من اتصالك، ثم أعد المحاولة."],
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index 4109c4a46..7781a039e 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -14741,6 +14741,10 @@ msgstr "تعذّرت إضافة المحادثة إلى هذا التقرير."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "النسخة من “{name}” المحفوظة في {scopeLabel} هي نسخة مكررة زائدة: تم التحقق من أن الأصل لم يتغير. احذف تلك النسخة ثم أعد محاولة النقل."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "تعذّرت إضافة تفريغ الأعطال إلى هذا التقرير."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "الفرع الافتراضي محمي — يتطلب الدفع طلب سحب."
diff --git a/packages/app/src/locales/bn/messages.json b/packages/app/src/locales/bn/messages.json
index aaa4dff49..7ea61ce5b 100644
--- a/packages/app/src/locales/bn/messages.json
+++ b/packages/app/src/locales/bn/messages.json
@@ -230,6 +230,7 @@
"1ouiTz": ["বাদ দেওয়া ছবি ", ["identity"], "। রেফারেন্সে যান।"],
"1pdLQw": ["ছবি পাওয়া যায়নি"],
"1qpGKz": ["পরিবর্তনগুলি সংরক্ষণ করা যায়নি। একটি রং আবার সম্পাদনা করে দেখুন।"],
+ "1rsUiG": ["ক্র্যাশ ডাম্পটি এই রিপোর্টে যোগ করা যায়নি।"],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["প্রত্যাখ্যান করুন"],
"1u-mAI": ["সিঙ্ক শুরু করা যায়নি। আপনার সংযোগ দেখুন, তারপর আবার চেষ্টা করুন।"],
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index c06e16eab..41ffe0725 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -14737,6 +14737,10 @@ msgstr "কথোপকথনটি এই রিপোর্টে যোগ
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "{scopeLabel}-এ রাখা “{name}”-এর কপিটি একটি অপ্রয়োজনীয় নকল: যাচাই করে দেখা গেছে মূলটি অপরিবর্তিত আছে। ওই কপিটি মুছে ফেলুন, তারপর সরানোর কাজটি আবার চেষ্টা করুন।"
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "ক্র্যাশ ডাম্পটি এই রিপোর্টে যোগ করা যায়নি।"
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "ডিফল্ট ব্রাঞ্চটি সুরক্ষিত — পাঠাতে একটি পুল রিকোয়েস্ট লাগে।"
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index f93b78d70..395fabe98 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -238,6 +238,7 @@
"1ouiTz": ["Excluded image ", ["identity"], ". Go to reference."],
"1pdLQw": ["Image not found"],
"1qpGKz": ["Couldn’t save changes. Try editing a color again."],
+ "1rsUiG": ["The crash dump couldn't be added to this report."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["Reject"],
"1u-mAI": ["Couldn't start the sync. Check your connection, then retry."],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 002668c00..636031497 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -14741,6 +14741,10 @@ msgstr "The conversation couldn't be added to this report."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "The crash dump couldn't be added to this report."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "The default branch is protected — pushes need a pull request."
diff --git a/packages/app/src/locales/es/messages.json b/packages/app/src/locales/es/messages.json
index 7fd94fb1a..80c574bb3 100644
--- a/packages/app/src/locales/es/messages.json
+++ b/packages/app/src/locales/es/messages.json
@@ -272,6 +272,7 @@
"1ouiTz": ["Imagen ", ["identity"], " excluida. Ir a la referencia."],
"1pdLQw": ["No se encontró la imagen"],
"1qpGKz": ["No se pudieron guardar los cambios. Intenta editar un color de nuevo."],
+ "1rsUiG": ["No se pudo añadir el volcado de fallo a este informe."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["Rechazar"],
"1u-mAI": ["No se pudo iniciar la sincronización. Revisa tu conexión y vuelve a intentarlo."],
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index 95f934720..ee3edd93f 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -14741,6 +14741,10 @@ msgstr "No se pudo añadir la conversación a este informe."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "La copia de «{name}» conservada en {scopeLabel} es un duplicado redundante: se verificó que el original no cambió. Elimina esa copia y vuelve a intentar el movimiento."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "No se pudo añadir el volcado de fallo a este informe."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "La rama por defecto está protegida: los push requieren una pull request."
diff --git a/packages/app/src/locales/fr/messages.json b/packages/app/src/locales/fr/messages.json
index fe021f463..e7ff35ae7 100644
--- a/packages/app/src/locales/fr/messages.json
+++ b/packages/app/src/locales/fr/messages.json
@@ -284,6 +284,7 @@
"1qpGKz": [
"Impossible d’enregistrer les modifications. Essayez à nouveau de modifier une couleur."
],
+ "1rsUiG": ["Impossible d'ajouter le vidage de plantage à ce rapport."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["Rejeter"],
"1u-mAI": [
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 6121330a8..a88ffcc2b 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -14741,6 +14741,10 @@ msgstr "Impossible d'ajouter la conversation à ce rapport."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "La copie de « {name} » conservée dans {scopeLabel} est un doublon redondant : l'original a été vérifié comme inchangé. Supprimez cette copie, puis réessayez le déplacement."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "Impossible d'ajouter le vidage de plantage à ce rapport."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "La branche par défaut est protégée — les push nécessitent une pull request."
diff --git a/packages/app/src/locales/hi/messages.json b/packages/app/src/locales/hi/messages.json
index 159bfe95f..9bdecb59c 100644
--- a/packages/app/src/locales/hi/messages.json
+++ b/packages/app/src/locales/hi/messages.json
@@ -232,6 +232,7 @@
"1ouiTz": ["बहिष्कृत चित्र ", ["identity"], "। संदर्भ पर जाएँ।"],
"1pdLQw": ["छवि नहीं मिली"],
"1qpGKz": ["बदलाव सहेजे नहीं जा सके। किसी रंग को फिर से संपादित करें।"],
+ "1rsUiG": ["क्रैश डंप को इस रिपोर्ट में नहीं जोड़ा जा सका।"],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["अस्वीकारें"],
"1u-mAI": ["सिंक शुरू नहीं किया जा सका। अपना कनेक्शन जाँचें, फिर कोशिश करें।"],
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index 699d1574e..3f70a450b 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -14737,6 +14737,10 @@ msgstr "बातचीत को इस रिपोर्ट में नह
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "{scopeLabel} में रखी गई “{name}” की कॉपी एक ग़ैरज़रूरी नक़ल है: जाँच में मूल अपरिवर्तित मिला। उस कॉपी को हटाएँ, फिर मूव दोबारा आज़माएँ।"
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "क्रैश डंप को इस रिपोर्ट में नहीं जोड़ा जा सका।"
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "डिफ़ॉल्ट ब्रांच सुरक्षित है — भेजने के लिए एक पुल रिक्वेस्ट चाहिए।"
diff --git a/packages/app/src/locales/id/messages.json b/packages/app/src/locales/id/messages.json
index 06240dea4..87667c30b 100644
--- a/packages/app/src/locales/id/messages.json
+++ b/packages/app/src/locales/id/messages.json
@@ -234,6 +234,7 @@
"1ouiTz": ["Gambar ", ["identity"], " dikecualikan. Buka referensi."],
"1pdLQw": ["Gambar tidak ditemukan"],
"1qpGKz": ["Perubahan tidak dapat disimpan. Coba sunting warna lagi."],
+ "1rsUiG": ["Crash dump tidak dapat ditambahkan ke laporan ini."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["Tolak"],
"1u-mAI": ["Sinkronisasinya tidak bisa dimulai. Periksa koneksi Anda, lalu coba lagi."],
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index 0364ad4f7..c437ebff3 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -14737,6 +14737,10 @@ msgstr "Percakapan tidak dapat ditambahkan ke laporan ini."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "Salinan “{name}” yang disimpan di {scopeLabel} adalah duplikat yang tidak diperlukan: aslinya sudah diverifikasi tidak berubah. Hapus salinan itu, lalu coba pemindahan lagi."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "Crash dump tidak dapat ditambahkan ke laporan ini."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "Cabang bawaannya terlindungi — push memerlukan pull request."
diff --git a/packages/app/src/locales/ko/messages.json b/packages/app/src/locales/ko/messages.json
index 546953eac..006bbec79 100644
--- a/packages/app/src/locales/ko/messages.json
+++ b/packages/app/src/locales/ko/messages.json
@@ -225,6 +225,7 @@
"1ouiTz": ["제외된 이미지 ", ["identity"], ". 참조로 이동합니다."],
"1pdLQw": ["이미지를 찾을 수 없음"],
"1qpGKz": ["변경사항을 저장하지 못했습니다. 색상을 다시 편집합니다."],
+ "1rsUiG": ["크래시 덤프를 이 보고서에 추가하지 못했습니다."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["거부"],
"1u-mAI": ["동기화를 시작할 수 없습니다. 연결을 확인한 후 다시 시도하세요."],
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 024f81319..b73e67ad7 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -14741,6 +14741,10 @@ msgstr "대화를 이 보고서에 추가하지 못했습니다."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "{scopeLabel}에 남아 있는 “{name}” 사본은 불필요한 중복입니다. 원본이 변경되지 않았음을 확인했습니다. 그 사본을 삭제한 뒤 이동을 다시 시도하세요."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "크래시 덤프를 이 보고서에 추가하지 못했습니다."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "기본 브랜치가 보호되어 푸시하려면 풀 리퀘스트가 필요합니다."
diff --git a/packages/app/src/locales/pl/messages.json b/packages/app/src/locales/pl/messages.json
index 467516b2a..929382d38 100644
--- a/packages/app/src/locales/pl/messages.json
+++ b/packages/app/src/locales/pl/messages.json
@@ -291,6 +291,7 @@
"1ouiTz": ["Wykluczony obraz ", ["identity"], ". Przejdź do odnośnika."],
"1pdLQw": ["Nie znaleziono obrazu"],
"1qpGKz": ["Nie udało się zapisać zmian. Spróbuj ponownie edytować kolor."],
+ "1rsUiG": ["Nie udało się dodać zrzutu awarii do tego zgłoszenia."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["Odrzuć"],
"1u-mAI": [
diff --git a/packages/app/src/locales/pl/messages.po b/packages/app/src/locales/pl/messages.po
index 321a062b2..46b713616 100644
--- a/packages/app/src/locales/pl/messages.po
+++ b/packages/app/src/locales/pl/messages.po
@@ -14741,6 +14741,10 @@ msgstr "Nie udało się dodać rozmowy do tego zgłoszenia."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "Kopia „{name}” przechowywana w {scopeLabel} jest zbędnym duplikatem: oryginał został zweryfikowany jako niezmieniony. Usuń tę kopię, a następnie ponów przenoszenie."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "Nie udało się dodać zrzutu awarii do tego zgłoszenia."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "Gałąź domyślna jest chroniona — push wymaga pull requesta."
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 122f12a71..942adf1e8 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -238,6 +238,7 @@
"1ouiTz": ["Ēxćĺũďēď ĩḿàĝē ", ["identity"], ". Ĝō ţō ŕēƒēŕēńćē."],
"1pdLQw": ["Ĩḿàĝē ńōţ ƒōũńď"],
"1qpGKz": ["Ćōũĺďń’ţ śàvē ćĥàńĝēś. Ţŕŷ ēďĩţĩńĝ à ćōĺōŕ àĝàĩń."],
+ "1rsUiG": ["Ţĥē ćŕàśĥ ďũḿƥ ćōũĺďń'ţ ƀē àďďēď ţō ţĥĩś ŕēƥōŕţ."],
"1ruosn": ["ŌƥēńĶńōŵĺēďĝē"],
"1t_NnN": ["ŔēĴēćţ"],
"1u-mAI": ["Ćōũĺďń'ţ śţàŕţ ţĥē śŷńć. Ćĥēćķ ŷōũŕ ćōńńēćţĩōń, ţĥēń ŕēţŕŷ."],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index f821041e2..54c23e36c 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -14737,6 +14737,10 @@ msgstr ""
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr ""
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr ""
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr ""
diff --git a/packages/app/src/locales/pt-BR/messages.json b/packages/app/src/locales/pt-BR/messages.json
index 8631fa074..71eef7f6f 100644
--- a/packages/app/src/locales/pt-BR/messages.json
+++ b/packages/app/src/locales/pt-BR/messages.json
@@ -272,6 +272,7 @@
"1ouiTz": ["A imagem ", ["identity"], " está ignorada. Ir para a referência."],
"1pdLQw": ["Imagem não encontrada"],
"1qpGKz": ["Não foi possível salvar as alterações. Tente editar uma cor novamente."],
+ "1rsUiG": ["Não foi possível adicionar o despejo de falha a este relatório."],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["Rejeitar"],
"1u-mAI": ["Não deu para iniciar a sincronização. Verifique sua conexão e tente de novo."],
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index 375c8a8ea..4088066ff 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -14737,6 +14737,10 @@ msgstr "Não foi possível adicionar a conversa a este relatório."
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "A cópia de “{name}” mantida em {scopeLabel} é uma duplicata redundante: o original foi verificado e está inalterado. Remova essa cópia e tente a movimentação de novo."
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "Não foi possível adicionar o despejo de falha a este relatório."
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "O ramo padrão é protegido — os envios exigem um pull request."
diff --git a/packages/app/src/locales/ur/messages.json b/packages/app/src/locales/ur/messages.json
index a11658598..24b7b6cbb 100644
--- a/packages/app/src/locales/ur/messages.json
+++ b/packages/app/src/locales/ur/messages.json
@@ -237,6 +237,7 @@
"1ouiTz": ["خارج شدہ تصویر ", ["identity"], "۔ حوالہ پر جائیں۔"],
"1pdLQw": ["تصویر نہیں ملی"],
"1qpGKz": ["تبدیلیاں محفوظ نہیں ہو سکیں۔ کسی رنگ میں دوبارہ ترمیم کر کے دیکھیں۔"],
+ "1rsUiG": ["کریش ڈمپ اس رپورٹ میں شامل نہیں کیا جا سکا۔"],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["مسترد کریں"],
"1u-mAI": ["مطابقت پذیری شروع نہیں ہو سکی۔ اپنا کنکشن دیکھیں، پھر دوبارہ کوشش کریں۔"],
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 65a3d5e70..2faa59774 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -14741,6 +14741,10 @@ msgstr "گفتگو اس رپورٹ میں شامل نہیں کی جا سکی۔"
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "{scopeLabel} میں رکھی گئی “{name}” کی کاپی ایک غیر ضروری نقل ہے: جانچ میں اصل غیر تبدیل شدہ پایا گیا۔ وہ کاپی حذف کریں، پھر منتقلی دوبارہ آزمائیں۔"
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "کریش ڈمپ اس رپورٹ میں شامل نہیں کیا جا سکا۔"
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "طے شدہ برانچ محفوظ ہے — پُش کے لیے پُل ریکویسٹ درکار ہے۔"
diff --git a/packages/app/src/locales/zh-Hans/messages.json b/packages/app/src/locales/zh-Hans/messages.json
index 4633f5f87..fbf6faf57 100644
--- a/packages/app/src/locales/zh-Hans/messages.json
+++ b/packages/app/src/locales/zh-Hans/messages.json
@@ -210,6 +210,7 @@
"1ouiTz": ["已排除的图片 ", ["identity"], "。转到引用位置。"],
"1pdLQw": ["找不到图片"],
"1qpGKz": ["无法保存更改。请再次编辑颜色。"],
+ "1rsUiG": ["无法将崩溃转储添加到此报告中。"],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["拒绝"],
"1u-mAI": ["无法开始同步。请检查你的网络连接,然后重试。"],
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index bc925bbe3..4f7b582b6 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -14741,6 +14741,10 @@ msgstr "无法将对话添加到此报告中。"
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "保留在{scopeLabel}中的“{name}”副本是多余的重复:原件已核实未被改动。请删除该副本,然后重试移动。"
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "无法将崩溃转储添加到此报告中。"
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "默认分支受保护——推送需要通过 pull request。"
diff --git a/packages/app/src/locales/zh-Hant/messages.json b/packages/app/src/locales/zh-Hant/messages.json
index 620636f26..f2aeda08b 100644
--- a/packages/app/src/locales/zh-Hant/messages.json
+++ b/packages/app/src/locales/zh-Hant/messages.json
@@ -212,6 +212,7 @@
"1ouiTz": ["已排除的圖片 ", ["identity"], "。前往引用位置。"],
"1pdLQw": ["找不到圖片"],
"1qpGKz": ["無法儲存變更。請再編輯一次色彩。"],
+ "1rsUiG": ["無法將當機傾印加入這份回報。"],
"1ruosn": ["OpenKnowledge"],
"1t_NnN": ["拒絕"],
"1u-mAI": ["無法開始同步。請檢查你的網路連線,然後再試一次。"],
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index d88b694aa..26d5dc941 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -14741,6 +14741,10 @@ msgstr "無法將對話加入這份回報。"
msgid "The copy of \"{name}\" kept in {scopeLabel} is a redundant duplicate: the original was verified unchanged. Remove that copy, then retry the move."
msgstr "保留在{scopeLabel}中的「{name}」副本是多餘的重複:原件已核實未被更動。請刪除該副本,然後重試移動。"
+#: src/components/ReportBugDialogBody.tsx
+msgid "The crash dump couldn't be added to this report."
+msgstr "無法將當機傾印加入這份回報。"
+
#: src/components/SyncStatusBadge.tsx
msgid "The default branch is protected — pushes need a pull request."
msgstr "預設分支受保護——推送需要透過 pull request。"
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 7a5eb0ef0..cdf75990e 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -1239,6 +1239,7 @@ export interface OkDesktopBridge {
includeScreenshot?: boolean;
attachments?: OkBugReportAttachmentInput[];
agentChatThreadId?: string;
+ crashEventId?: string;
}): Promise<OkBugReportCreateResult>;
captureScreenshot(): Promise<OkBugReportScreenshot | null>;
crashDumpAvailability(): Promise<OkBugReportCrashDumpAvailability>;
diff --git a/packages/desktop/src/main/crash-detection.test.ts b/packages/desktop/src/main/crash-detection.test.ts
index e8f20c509..5dcd3dd49 100644
--- a/packages/desktop/src/main/crash-detection.test.ts
+++ b/packages/desktop/src/main/crash-detection.test.ts
@@ -4,6 +4,7 @@ import {
mkdtempSync,
readFileSync,
rmSync,
+ statSync,
utimesSync,
writeFileSync,
} from 'node:fs';
@@ -60,6 +61,8 @@ interface Rig {
ownDumpWithAxMode(version: string, mode: string): Buffer;
ownDumpWithProcessType(processType: string, version?: string): Buffer;
ownDumpSimulated: Buffer;
+ ownDumpCrashed: Buffer;
+ ownSizedForeignDump: Buffer;
setRendererAvailable(available: boolean): void;
setBootSessionUuid(uuid: string | null): void;
setInstallInFlight(inFlight: InstallInFlight | null): void;
@@ -108,6 +111,12 @@ function makeRig(): Rig {
infos,
ownDump: buildMinidump(ownModules),
ownDumpSimulated: buildMinidump(ownModules, { exceptionCode: 0x4350_7378 }),
+ ownDumpCrashed: buildMinidump(ownModules, { exceptionCode: 0xc000_0005 }),
+ ownSizedForeignDump: buildMinidump(
+ ownModules.map((modulePath) =>
+ modulePath.replace(appBundleRoot, join(dir, 'Applicationz', 'OpenKnowledge.app')),
+ ),
+ ),
ownDumpStamped: (version: string) =>
buildMinidump(ownModules, {
annotations: { _productName: 'OpenKnowledge', _version: version, prod: 'Electron' },
@@ -1154,7 +1163,7 @@ describe('crash-dump ownership filtering', () => {
expect(
warnLines.find((line) => line.event === 'crash-detection.render-process-gone')
- ?.foreignDumpsIgnored,
+ ?.deathWindowForeignSkipped,
).toBe(1);
});
@@ -1173,8 +1182,8 @@ describe('crash-dump ownership filtering', () => {
detection.handleRenderProcessGone({ reason: 'crashed' });
const line = warnLines.find((l) => l.event === 'crash-detection.render-process-gone');
- expect(line?.unreadableDumpsSkipped).toBe(1);
- expect(line?.foreignDumpsIgnored).toBe(0);
+ expect(line?.deathWindowUnreadableSkipped).toBe(1);
+ expect(line?.deathWindowForeignSkipped).toBe(0);
expect(rig.emitted[0]?.minidumpAvailable).toBe(false);
});
@@ -1193,7 +1202,7 @@ describe('crash-dump ownership filtering', () => {
detection.handleChildProcessGone({ type: 'Utility', reason: 'crashed' });
const line = warnLines.find((l) => l.event === 'crash-detection.child-process-gone');
- expect(line?.foreignDumpsIgnored).toBe(0);
+ expect(line?.deathWindowForeignSkipped).toBe(0);
expect(rig.emitted[0]?.minidumpAvailable).toBe(true);
});
@@ -1736,9 +1745,9 @@ describe('non-crash minidumps', () => {
detection.handleRenderProcessGone({ reason: 'crashed', exitCode: 5 });
const logged = rig.warnings.at(-1);
- expect(logged?.nonCrashDumpsSkipped).toBe(1);
- expect(logged?.foreignDumpsIgnored).toBe(0);
- expect(logged?.unreadableDumpsSkipped).toBe(0);
+ expect(logged?.deathWindowSnapshotSkipped).toBe(1);
+ expect(logged?.deathWindowForeignSkipped).toBe(0);
+ expect(logged?.deathWindowUnreadableSkipped).toBe(0);
});
});
@@ -3515,3 +3524,559 @@ describe('how the previous main process exited', () => {
expect(parseMainExitRecord('{"schemaVersion":1')).toBeNull();
});
});
+
+describe('the dump a report invitation is bound to', () => {
+ function afterCleanQuit(rig: Rig): void {
+ const sessionA = createCrashDetection(rig.deps);
+ sessionA.detectBootCrash();
+ sessionA.markCleanQuit();
+ }
+
+ function overwriteKeepingStamp(path: string, bytes: Buffer): void {
+ const { mtime } = statSync(path);
+ writeFileSync(path, bytes);
+ utimesSync(path, mtime, mtime);
+ }
+
+ test('a boot invitation binds the dump that armed it, not one written after detection', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const armingPath = seedMinidump(rig, 'pending/first-crash.dmp', rig.tick());
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ seedMinidump(rig, 'pending/second-crash.dmp', rig.tick());
+
+ expect(session.newestMinidumpForReport().path).not.toBe(armingPath);
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'bound',
+ path: armingPath,
+ });
+ });
+
+ test('Crashpad moving the bound dump between its database folders keeps the binding', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const at = rig.tick();
+ const pendingPath = seedMinidump(rig, 'pending/moved.dmp', at);
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ const completedPath = seedMinidump(rig, 'completed/moved.dmp', at);
+ rmSync(pendingPath);
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'bound',
+ path: completedPath,
+ });
+ });
+
+ test('a bound dump Crashpad rotated away is reported missing, never substituted', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const armingPath = seedMinidump(rig, 'pending/rotated.dmp', rig.tick());
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ seedMinidump(rig, 'pending/later.dmp', rig.tick());
+ rmSync(armingPath);
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-missing',
+ });
+ });
+
+ test('a bound dump whose bytes changed size is reported changed', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const armingPath = seedMinidump(rig, 'pending/rewritten.dmp', rig.tick());
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ overwriteKeepingStamp(armingPath, Buffer.concat([rig.ownDump, Buffer.from([0])]));
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-changed',
+ });
+ });
+
+ test('two files answering to the bound dump are reported ambiguous', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const at = rig.tick();
+ seedMinidump(rig, 'pending/twin.dmp', at);
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ seedMinidump(rig, 'completed/twin.dmp', at);
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-ambiguous',
+ });
+ });
+
+ test('a bound dump that now names another application is re-checked and refused as not ours', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const armingPath = seedMinidump(rig, 'pending/claimed.dmp', rig.tick());
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ expect(rig.ownSizedForeignDump.length).toBe(rig.ownDump.length);
+ overwriteKeepingStamp(armingPath, rig.ownSizedForeignDump);
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-not-owned',
+ });
+ });
+
+ test('a bound dump that can no longer be read is reported unreadable, not as foreign', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const armingPath = seedMinidump(rig, 'pending/torn.dmp', rig.tick());
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ overwriteKeepingStamp(armingPath, Buffer.alloc(rig.ownDump.length, 0x41));
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-unreadable',
+ });
+ });
+
+ test('a bound dump that now reads as a snapshot is re-checked and refused', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const armingPath = seedMinidump(rig, 'pending/crashed.dmp', rig.tick(), rig.ownDumpCrashed);
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ expect(rig.ownDumpSimulated.length).toBe(rig.ownDumpCrashed.length);
+ overwriteKeepingStamp(armingPath, rig.ownDumpSimulated);
+
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-non-crash',
+ });
+ });
+
+ test('a dirty shutdown with no dump binds none, even once a dump appears', () => {
+ const rig = makeRig();
+ createCrashDetection(rig.deps).detectBootCrash();
+
+ const session = createCrashDetection(rig.deps);
+ const armed = bootInvite(session.detectBootCrash());
+ expect(armed.minidumpAvailable).toBe(false);
+ seedMinidump(rig, 'pending/after-recovery.dmp', rig.tick());
+
+ expect(session.newestMinidumpForReport().path).not.toBeNull();
+ expect(session.minidumpForCrashEvent(armed.eventId)).toEqual({ status: 'none-bound' });
+ });
+
+ test('an event this process never armed is unbound, whatever is on disk', () => {
+ const rig = makeRig();
+ afterCleanQuit(rig);
+ const session = createCrashDetection(rig.deps);
+ expect(session.detectBootCrash()).toBeNull();
+ seedMinidump(rig, 'pending/unrelated.dmp', rig.tick());
+
+ expect(session.minidumpForCrashEvent('boot:dump:1')).toEqual({
+ status: 'omitted',
+ reason: 'invitation-unbound',
+ });
+ });
+
+ test('a renderer crash binds the dump on disk when it died; a later crash stays silent and unbound', () => {
+ const rig = makeRig();
+ const detection = createCrashDetection(rig.deps);
+ const firstPath = seedMinidump(rig, 'completed/renderer-a.dmp', rig.tick());
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const first = rig.emitted[0];
+ if (first === undefined) throw new Error('expected a renderer invitation');
+
+ seedMinidump(rig, 'completed/renderer-b.dmp', rig.tick());
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+
+ expect(rig.emitted).toHaveLength(1);
+ expect(detection.minidumpForCrashEvent(first.eventId)).toEqual({
+ status: 'bound',
+ path: firstPath,
+ });
+ });
+
+ test('a child-process crash binds its own dump on disk, past a newer foreign dump and a later crash', () => {
+ const rig = makeRig();
+ const detection = createCrashDetection(rig.deps);
+ const ownPath = seedMinidump(rig, 'completed/utility.dmp', rig.tick());
+ seedMinidump(rig, 'completed/foreign.dmp', rig.tick(), FOREIGN_DUMP);
+ detection.handleChildProcessGone({ type: 'Utility', reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a child-process invitation');
+ expect(invite.kind).toBe('child-process-gone');
+
+ const laterPath = seedMinidump(rig, 'completed/later.dmp', rig.tick());
+
+ expect(detection.newestMinidumpForReport().path).toBe(laterPath);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'bound',
+ path: ownPath,
+ });
+ });
+
+ function sessionOnStoppedClock(rig: Rig) {
+ rig.deps.now = () => new Date(rig.nowMs());
+ const detection = createCrashDetection(rig.deps);
+ rig.advance(60_000);
+ return detection;
+ }
+
+ function deathLine(rig: Rig, eventId: string): Record<string, unknown> | undefined {
+ return rig.warnings.find((line) => line.eventId === eventId);
+ }
+
+ test('a renderer dump that lands after the death is offered and bound to that death', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ rig.setRendererAvailable(false);
+ const diedAtMs = rig.nowMs();
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ rig.advance(2_000);
+ const dumpPath = seedMinidump(
+ rig,
+ 'pending/renderer.dmp',
+ new Date(diedAtMs + 2_000),
+ rig.ownDumpWithProcessType('renderer'),
+ );
+ rig.advance(3_000);
+
+ rig.setRendererAvailable(true);
+ detection.notifyRendererReady();
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ expect(invite.eventId).toBe(`crash:render:${diedAtMs}:0`);
+ expect(deathLine(rig, invite.eventId)?.deathWindowOutcome).toBe('no-dump-near-death');
+ expect(
+ rig.infos.find(
+ (line) => line.event === 'crash-detection.invitation-dump-availability-changed',
+ ),
+ ).toMatchObject({ eventId: invite.eventId, minidumpAvailable: true });
+ expect(
+ rig.infos.find((line) => line.event === 'crash-detection.invitation-dump-bound'),
+ ).toMatchObject({ eventId: invite.eventId, deathWindowDump: 'renderer.dmp' });
+ expect(rig.infos.some((line) => line.event === 'crash-detection.invitation-dump-rebound')).toBe(
+ false,
+ );
+
+ expect(invite.minidumpAvailable).toBe(true);
+ rig.advance(60_000);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'bound',
+ path: dumpPath,
+ });
+ expect(
+ rig.infos.find((line) => line.event === 'crash-detection.invitation-dump-settled'),
+ ).toMatchObject({ eventId: invite.eventId, settledDump: 'renderer.dmp', settledFrom: 'scan' });
+ });
+
+ test('a dump Crashpad was still writing when the renderer died binds in its finished form', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ const diedAtMs = rig.nowMs();
+ const writingPath = seedMinidump(rig, 'new/renderer.dmp', new Date(diedAtMs - 1_000));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ expect(invite.eventId).toBe(`crash:render:${diedAtMs}:0`);
+ expect(invite.minidumpAvailable).toBe(true);
+
+ expect(rig.ownDumpCrashed.length).not.toBe(rig.ownDump.length);
+ rig.advance(1_000);
+ rmSync(writingPath);
+ const finishedPath = seedMinidump(
+ rig,
+ 'pending/renderer.dmp',
+ new Date(diedAtMs + 1_000),
+ rig.ownDumpCrashed,
+ );
+ rig.advance(60_000);
+
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'bound',
+ path: finishedPath,
+ });
+ });
+
+ test('the death log names the dump the death-window scan bound, and no path', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ seedMinidump(rig, 'completed/foreign.dmp', new Date(rig.nowMs() - 500), FOREIGN_DUMP);
+ seedMinidump(rig, 'completed/renderer.dmp', new Date(rig.nowMs() - 1_000));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+
+ const line = deathLine(rig, invite.eventId);
+ expect(line).toMatchObject({
+ event: 'crash-detection.render-process-gone',
+ deathWindowOutcome: 'bound',
+ deathWindowDump: 'renderer.dmp',
+ deathWindowDumpCount: 2,
+ deathWindowForeignSkipped: 1,
+ deathWindowAcknowledgedSkipped: 0,
+ });
+ expect(JSON.stringify(line)).not.toContain(rig.dir);
+ });
+
+ test('a crash after the user dismissed the last one never binds the dismissed dump', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ seedMinidump(rig, 'completed/first.dmp', new Date(rig.nowMs() - 1_000));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const first = rig.emitted[0];
+ if (first === undefined) throw new Error('expected the first renderer invitation');
+ expect(first.minidumpAvailable).toBe(true);
+ rig.advance(5_000);
+ detection.ack(first.eventId);
+ rig.advance(5_000);
+
+ const secondDiedAtMs = rig.nowMs();
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const second = rig.emitted[1];
+ if (second === undefined) throw new Error('expected the second renderer invitation');
+
+ expect(second.minidumpAvailable).toBe(false);
+ expect(deathLine(rig, second.eventId)).toMatchObject({
+ deathWindowOutcome: 'none-attachable',
+ deathWindowDump: null,
+ deathWindowAcknowledgedSkipped: 1,
+ });
+ rig.advance(15_000);
+ const ownPath = seedMinidump(rig, 'completed/second.dmp', new Date(secondDiedAtMs + 15_000));
+ rig.advance(60_000);
+ expect(detection.minidumpForCrashEvent(second.eventId)).toEqual({
+ status: 'bound',
+ path: ownPath,
+ });
+ });
+
+ test('once the death window has closed, a vanished bound dump is reported missing, not replaced', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ const diedAtMs = rig.nowMs();
+ const boundPath = seedMinidump(rig, 'completed/bound.dmp', new Date(diedAtMs - 1_000));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ expect(invite.minidumpAvailable).toBe(true);
+
+ rig.advance(60_000);
+ rmSync(boundPath);
+ seedMinidump(rig, 'completed/other.dmp', new Date(diedAtMs + 5_000));
+
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-missing',
+ });
+ expect(
+ rig.infos.find((line) => line.event === 'crash-detection.invitation-dump-settled'),
+ ).toMatchObject({
+ eventId: invite.eventId,
+ settledDump: 'bound.dmp',
+ settledFrom: 'held-missing',
+ heldDumpVanished: true,
+ });
+ });
+
+ test('a held dump the settling scan now skips settles as held, and staging says why it is left out', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ const diedAtMs = rig.nowMs();
+ const boundPath = seedMinidump(rig, 'completed/bound.dmp', new Date(diedAtMs - 1_000));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ expect(invite.minidumpAvailable).toBe(true);
+
+ rig.advance(2_000);
+ expect(UNPARSEABLE_DUMP.length).not.toBe(rig.ownDump.length);
+ seedMinidump(rig, 'completed/bound.dmp', new Date(diedAtMs + 2_000), UNPARSEABLE_DUMP);
+ expect(statSync(boundPath).size).toBe(UNPARSEABLE_DUMP.length);
+ rig.advance(60_000);
+
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'omitted',
+ reason: 'bound-dump-unreadable',
+ });
+ expect(
+ rig.infos.find((line) => line.event === 'crash-detection.invitation-dump-settled'),
+ ).toMatchObject({
+ eventId: invite.eventId,
+ settledDump: 'bound.dmp',
+ settledFrom: 'held',
+ heldDumpVanished: false,
+ deathWindowOutcome: 'none-attachable',
+ deathWindowUnreadableSkipped: 1,
+ });
+ });
+
+ function heldOlderDumpThenOwnDump(rig: Rig) {
+ const detection = sessionOnStoppedClock(rig);
+ const diedAtMs = rig.nowMs();
+ seedMinidump(rig, 'completed/older.dmp', new Date(diedAtMs - 20_000));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ expect(invite.minidumpAvailable).toBe(true);
+ rig.advance(1_000);
+ const ownPath = seedMinidump(rig, 'completed/own.dmp', new Date(diedAtMs + 1_000));
+ return { detection, invite, ownPath };
+ }
+
+ test('a closer dump of the death replaces an older held dump on a read inside the window', () => {
+ const rig = makeRig();
+ const { detection, invite, ownPath } = heldOlderDumpThenOwnDump(rig);
+
+ rig.advance(1_000);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'bound',
+ path: ownPath,
+ });
+ expect(
+ rig.infos.find((line) => line.event === 'crash-detection.invitation-dump-rebound'),
+ ).toMatchObject({
+ eventId: invite.eventId,
+ previousDump: 'older.dmp',
+ deathWindowDump: 'own.dmp',
+ });
+ rig.advance(60_000);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'bound',
+ path: ownPath,
+ });
+ });
+
+ test('a held binding first read after the window settles by the same rule as one read inside it', () => {
+ const rig = makeRig();
+ const { detection, invite, ownPath } = heldOlderDumpThenOwnDump(rig);
+
+ rig.advance(60_000);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({
+ status: 'bound',
+ path: ownPath,
+ });
+ });
+
+ test('a binding that settles with no dump records why nothing near the death qualified', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ const diedAtMs = rig.nowMs();
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ rig.advance(2_000);
+ seedMinidump(rig, 'completed/torn.dmp', new Date(diedAtMs + 2_000), UNPARSEABLE_DUMP);
+ rig.advance(60_000);
+
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({ status: 'none-bound' });
+ expect(
+ rig.infos.find((line) => line.event === 'crash-detection.invitation-dump-settled'),
+ ).toMatchObject({
+ eventId: invite.eventId,
+ settledDump: null,
+ settledFrom: 'none',
+ heldDumpVanished: false,
+ deathWindowOutcome: 'none-attachable',
+ deathWindowDumpCount: 1,
+ deathWindowUnreadableSkipped: 1,
+ });
+ });
+
+ test('an owned crash dump just outside 30 s of the death is never bound to it', () => {
+ const rig = makeRig();
+ const detection = sessionOnStoppedClock(rig);
+ seedMinidump(rig, 'completed/earlier.dmp', new Date(rig.nowMs() - 30_001));
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+
+ expect(invite.minidumpAvailable).toBe(false);
+ expect(deathLine(rig, invite.eventId)?.deathWindowOutcome).toBe('no-dump-near-death');
+ rig.advance(60_000);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({ status: 'none-bound' });
+
+ const edgeRig = makeRig();
+ const edge = sessionOnStoppedClock(edgeRig);
+ const edgePath = seedMinidump(
+ edgeRig,
+ 'completed/edge.dmp',
+ new Date(edgeRig.nowMs() - 30_000),
+ );
+ edge.handleRenderProcessGone({ reason: 'crashed' });
+ const edgeInvite = edgeRig.emitted[0];
+ if (edgeInvite === undefined) throw new Error('expected a renderer invitation');
+ expect(edgeInvite.minidumpAvailable).toBe(true);
+ edgeRig.advance(60_000);
+ expect(edge.minidumpForCrashEvent(edgeInvite.eventId)).toEqual({
+ status: 'bound',
+ path: edgePath,
+ });
+ });
+
+ test('a declined GPU death leaves a dump that is never bound to a later renderer invitation', () => {
+ const rig = makeRig();
+ const detection = createCrashDetection(rig.deps);
+ detection.handleChildProcessGone({ type: 'GPU', reason: 'crashed' });
+ expect(rig.emitted).toHaveLength(0);
+ seedMinidump(
+ rig,
+ 'completed/gpu.dmp',
+ new Date(rig.nowMs()),
+ rig.ownDumpWithProcessType('gpu-process'),
+ );
+ rig.setRendererAvailable(false);
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+
+ rig.setRendererAvailable(true);
+ detection.notifyRendererReady();
+ const invite = rig.emitted[0];
+ if (invite === undefined) throw new Error('expected a renderer invitation');
+ rig.advance(60_000);
+
+ expect(invite.minidumpAvailable).toBe(false);
+ expect(detection.minidumpForCrashEvent(invite.eventId)).toEqual({ status: 'none-bound' });
+ });
+
+ test('a boot invitation prefers the dump that armed it over a newer dump of a declined death', () => {
+ const rig = makeRig();
+ const sessionA = createCrashDetection(rig.deps);
+ expect(sessionA.detectBootCrash()).toBeNull();
+ const rendererPath = seedMinidump(
+ rig,
+ 'completed/renderer.dmp',
+ rig.tick(),
+ rig.ownDumpWithProcessType('renderer'),
+ );
+ sessionA.handleChildProcessGone({ type: 'GPU', reason: 'crashed' });
+ seedMinidump(
+ rig,
+ 'completed/gpu.dmp',
+ new Date(rig.nowMs() + 5_000),
+ rig.ownDumpWithProcessType('gpu-process'),
+ );
+ sessionA.markCleanQuit();
+
+ const sessionB = createCrashDetection(rig.deps);
+ const armed = bootInvite(sessionB.detectBootCrash());
+
+ expect(armed.minidumpAvailable).toBe(true);
+ expect(sessionB.minidumpForCrashEvent(armed.eventId)).toEqual({
+ status: 'bound',
+ path: rendererPath,
+ });
+ });
+});
diff --git a/packages/desktop/src/main/crash-detection.ts b/packages/desktop/src/main/crash-detection.ts
index d52c02776..c326310d0 100644
--- a/packages/desktop/src/main/crash-detection.ts
+++ b/packages/desktop/src/main/crash-detection.ts
@@ -7,7 +7,7 @@ import {
statSync,
writeFileSync,
} from 'node:fs';
-import { dirname, join } from 'node:path';
+import { basename, dirname, join } from 'node:path';
import {
MINIDUMP_FILE_EXTENSION,
type OkBugReportCrashDetectedEvent,
@@ -59,7 +59,9 @@ export const STALE_CRASH_AFTER_MS = 7 * 24 * 60 * 60_000;
const MAX_ACKED_EVENT_IDS = 50;
-const DECLINED_DEATH_DUMP_MATCH_MS = 30_000;
+const MAX_BOUND_INVITATIONS = 16;
+
+const DEATH_DUMP_MATCH_MS = 30_000;
export const MAX_DECLINED_DEATHS = 600;
@@ -201,6 +203,7 @@ export interface CrashDetection {
notifyRendererReady(): void;
ack(eventId: string): void;
newestMinidumpForReport(): MinidumpReportLookup;
+ minidumpForCrashEvent(eventId: string): CrashEventMinidumpLookup;
}
export interface MinidumpReportLookup {
@@ -209,6 +212,70 @@ export interface MinidumpReportLookup {
unknownSkipped: number;
}
+export type BoundMinidumpOmission =
+ | 'invitation-unbound'
+ | 'bound-dump-missing'
+ | 'bound-dump-changed'
+ | 'bound-dump-ambiguous'
+ | 'bound-dump-not-owned'
+ | 'bound-dump-unreadable'
+ | 'bound-dump-non-crash';
+
+export type CrashEventMinidumpLookup =
+ | { status: 'bound'; path: string }
+ | { status: 'none-bound' }
+ | { status: 'omitted'; reason: BoundMinidumpOmission };
+
+interface BoundMinidump {
+ fileName: string;
+ sizeBytes: number;
+ mtimeMs: number;
+}
+
+type WithoutMinidumpAvailable<E> = E extends unknown ? Omit<E, 'minidumpAvailable'> : never;
+
+type RuntimeCrashEventDraft = WithoutMinidumpAvailable<
+ Exclude<OkBugReportCrashDetectedEvent, { kind: 'boot' }>
+>;
+
+type SettledFrom = 'scan' | 'held' | 'held-missing' | 'none';
+
+type InvitationBinding =
+ | { state: 'settled'; dump: BoundMinidump | null }
+ | { state: 'settling'; deathMs: number; dump: BoundMinidump | null };
+
+interface DeathWindowScan {
+ entry: MinidumpEntry | null;
+ dumpsNearDeath: number;
+ acknowledgedSkipped: number;
+ foreignSkipped: number;
+ unknownSkipped: number;
+ nonCrashSkipped: number;
+ declinedSkipped: number;
+}
+
+function deathWindowFacts(scan: DeathWindowScan): Record<string, string | number | null> {
+ return {
+ deathWindowOutcome:
+ scan.entry !== null
+ ? 'bound'
+ : scan.dumpsNearDeath === 0
+ ? 'no-dump-near-death'
+ : 'none-attachable',
+ deathWindowDump: scan.entry === null ? null : basename(scan.entry.path),
+ deathWindowDumpCount: scan.dumpsNearDeath,
+ deathWindowAcknowledgedSkipped: scan.acknowledgedSkipped,
+ deathWindowForeignSkipped: scan.foreignSkipped,
+ deathWindowUnreadableSkipped: scan.unknownSkipped,
+ deathWindowSnapshotSkipped: scan.nonCrashSkipped,
+ deathWindowDeclinedSkipped: scan.declinedSkipped,
+ };
+}
+
+function toBoundMinidump(entry: MinidumpEntry): BoundMinidump {
+ return { fileName: basename(entry.path), sizeBytes: entry.sizeBytes, mtimeMs: entry.mtimeMs };
+}
+
export function startLocalCrashReporter(reporter: {
start(options: { uploadToServer: boolean }): void;
}): void {
@@ -256,6 +323,7 @@ function parseAckStore(raw: string): CrashAckStore | null {
interface MinidumpEntry {
path: string;
mtimeMs: number;
+ sizeBytes: number;
}
function collectMinidumpEntries(dir: string, depth: number, out: MinidumpEntry[]): void {
@@ -273,7 +341,8 @@ function collectMinidumpEntries(dir: string, depth: number, out: MinidumpEntry[]
}
if (!entry.name.endsWith(MINIDUMP_FILE_EXTENSION)) continue;
try {
- out.push({ path: entryPath, mtimeMs: statSync(entryPath).mtimeMs });
+ const stats = statSync(entryPath);
+ out.push({ path: entryPath, mtimeMs: stats.mtimeMs, sizeBytes: stats.size });
} catch {}
}
}
@@ -285,6 +354,7 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
armedAtMs: number;
} | null = null;
let runtimeSeq = 0;
+ const boundDumps = new Map<string, InvitationBinding>();
let recentGpuCrashes: number[] = [];
@@ -375,7 +445,7 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
function declinedDeathForDump(entry: MinidumpEntry): DeclinedDeathMatch {
const near = store.declinedDeaths.filter((declined) => {
const at = epochMsOrNull(declined.at);
- return at !== null && Math.abs(entry.mtimeMs - at) <= DECLINED_DEATH_DUMP_MATCH_MS;
+ return at !== null && Math.abs(entry.mtimeMs - at) <= DEATH_DUMP_MATCH_MS;
});
if (near.length === 0) return { matched: null, read: 'not-asked' };
const { processType, parseFailed } = readMinidumpProcessType(entry.path);
@@ -390,7 +460,8 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
function tryDeliver(): void {
if (active === null || active.delivered) return;
- const pendingAgeMs = deps.now().getTime() - active.armedAtMs;
+ const nowMs = deps.now().getTime();
+ const pendingAgeMs = nowMs - active.armedAtMs;
if (pendingAgeMs >= INVITE_EXPIRE_AFTER_MS) {
deps.logger.info(
{
@@ -404,12 +475,174 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
active = null;
return;
}
+ if (boundDumps.get(active.event.eventId)?.state === 'settling') {
+ const minidumpAvailable =
+ (settleInvitation(active.event.eventId, nowMs)?.dump ?? null) !== null;
+ if (active.event.minidumpAvailable !== minidumpAvailable) {
+ deps.logger.info(
+ {
+ event: 'crash-detection.invitation-dump-availability-changed',
+ eventId: active.event.eventId,
+ minidumpAvailable,
+ },
+ 'the dump of this death changed before the invitation was delivered',
+ );
+ active.event = { ...active.event, minidumpAvailable };
+ }
+ }
if (deps.emit(active.event)) {
active.delivered = true;
}
}
- function armInvite(event: OkBugReportCrashDetectedEvent): boolean {
+ function bindInvitation(eventId: string, binding: InvitationBinding): void {
+ boundDumps.delete(eventId);
+ boundDumps.set(eventId, binding);
+ while (boundDumps.size > MAX_BOUND_INVITATIONS) {
+ const oldest = boundDumps.keys().next();
+ if (oldest.done === true) break;
+ boundDumps.delete(oldest.value);
+ }
+ }
+
+ function listMinidumpEntries(): MinidumpEntry[] {
+ const entries: MinidumpEntry[] = [];
+ collectMinidumpEntries(deps.crashDumpsDir, MINIDUMP_SCAN_DEPTH, entries);
+ return entries;
+ }
+
+ function scanDeathWindow(
+ deathMs: number,
+ entries: readonly MinidumpEntry[] = listMinidumpEntries(),
+ ): DeathWindowScan {
+ const near = entries
+ .map((entry) => ({ entry, distanceMs: Math.abs(entry.mtimeMs - deathMs) }))
+ .filter(({ distanceMs }) => distanceMs <= DEATH_DUMP_MATCH_MS)
+ .sort((a, b) => a.distanceMs - b.distanceMs || a.entry.mtimeMs - b.entry.mtimeMs);
+ const baselineMs = Date.parse(store.minidumpBaselineAt);
+ const scan: DeathWindowScan = {
+ entry: null,
+ dumpsNearDeath: near.length,
+ acknowledgedSkipped: 0,
+ foreignSkipped: 0,
+ unknownSkipped: 0,
+ nonCrashSkipped: 0,
+ declinedSkipped: 0,
+ };
+ for (const { entry } of near) {
+ if (!(entry.mtimeMs > baselineMs)) {
+ scan.acknowledgedSkipped += 1;
+ continue;
+ }
+ const ownership = classifyDump(entry.path);
+ if (ownership !== 'ours') {
+ if (ownership === 'foreign') scan.foreignSkipped += 1;
+ else scan.unknownSkipped += 1;
+ continue;
+ }
+ if (crashKindOf(entry.path) === 'non-crash') {
+ scan.nonCrashSkipped += 1;
+ continue;
+ }
+ if (declinedDeathForDump(entry).matched !== null) {
+ scan.declinedSkipped += 1;
+ continue;
+ }
+ scan.entry = entry;
+ break;
+ }
+ return scan;
+ }
+
+ function findHeldDump(
+ dump: BoundMinidump,
+ entries: readonly MinidumpEntry[],
+ ): BoundMinidump | null {
+ const matches = entries.filter((entry) => basename(entry.path) === dump.fileName);
+ const match = matches[0];
+ if (match === undefined) return null;
+ return matches.length === 1 ? toBoundMinidump(match) : dump;
+ }
+
+ function settleBinding(
+ eventId: string,
+ binding: InvitationBinding,
+ nowMs: number,
+ ): InvitationBinding {
+ if (binding.state === 'settled') return binding;
+ const windowOpen = nowMs < binding.deathMs + DEATH_DUMP_MATCH_MS;
+ const entries = listMinidumpEntries();
+ const scan = scanDeathWindow(binding.deathMs, entries);
+ const held = binding.dump === null ? null : findHeldDump(binding.dump, entries);
+ const heldDumpVanished = binding.dump !== null && held === null;
+ let settledFrom: SettledFrom = heldDumpVanished ? 'held-missing' : 'none';
+ if (!heldDumpVanished) {
+ if (scan.entry !== null) {
+ const next = toBoundMinidump(scan.entry);
+ if (binding.dump === null) {
+ deps.logger.info(
+ { event: 'crash-detection.invitation-dump-bound', eventId, ...deathWindowFacts(scan) },
+ 'a dump of this death appeared after the invitation armed and is now bound to it',
+ );
+ } else if (binding.dump.fileName !== next.fileName) {
+ deps.logger.info(
+ {
+ event: 'crash-detection.invitation-dump-rebound',
+ eventId,
+ previousDump: binding.dump.fileName,
+ ...deathWindowFacts(scan),
+ },
+ 'a dump closer to this death replaced the one bound to its invitation',
+ );
+ }
+ binding.dump = next;
+ settledFrom = 'scan';
+ } else if (held !== null) {
+ binding.dump = held;
+ settledFrom = 'held';
+ }
+ }
+ if (windowOpen) return binding;
+ deps.logger.info(
+ {
+ event: 'crash-detection.invitation-dump-settled',
+ eventId,
+ settledDump: binding.dump?.fileName ?? null,
+ settledFrom,
+ heldDumpVanished,
+ ...deathWindowFacts(scan),
+ },
+ heldDumpVanished
+ ? 'the dump bound to this death is gone, so its binding settles on the missing file'
+ : 'the dump bound to this death is now fixed',
+ );
+ return { state: 'settled', dump: binding.dump };
+ }
+
+ function settleInvitation(eventId: string, nowMs: number): InvitationBinding | undefined {
+ const binding = boundDumps.get(eventId);
+ if (binding === undefined) return undefined;
+ const settled = settleBinding(eventId, binding, nowMs);
+ if (settled !== binding) boundDumps.set(eventId, settled);
+ return settled;
+ }
+
+ function armRuntimeInvite(
+ event: RuntimeCrashEventDraft,
+ deathMs: number,
+ entry: MinidumpEntry | null,
+ ): boolean {
+ return armInvite(
+ { ...event, minidumpAvailable: entry !== null },
+ {
+ state: 'settling',
+ deathMs,
+ dump: entry === null ? null : toBoundMinidump(entry),
+ },
+ );
+ }
+
+ function armInvite(event: OkBugReportCrashDetectedEvent, binding: InvitationBinding): boolean {
const nowMs = deps.now().getTime();
if (active !== null) {
const pendingAgeMs = nowMs - active.armedAtMs;
@@ -436,6 +669,7 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
);
}
active = { event, delivered: false, armedAtMs: nowMs };
+ bindInvitation(event.eventId, binding);
return true;
}
@@ -458,8 +692,7 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
}
function freshMinidumpEntries(): MinidumpEntry[] {
- const entries: MinidumpEntry[] = [];
- collectMinidumpEntries(deps.crashDumpsDir, MINIDUMP_SCAN_DEPTH, entries);
+ const entries = listMinidumpEntries();
const baselineMs = Date.parse(store.minidumpBaselineAt);
return entries.filter((e) => e.mtimeMs > baselineMs).sort((a, b) => b.mtimeMs - a.mtimeMs);
}
@@ -666,9 +899,10 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
d.declined.matched === null &&
!d.handoffShadowed;
const newDumps = freshDumps.filter(arming).map((d) => d.entry.mtimeMs);
- const ownedDumpCount = freshDumps.filter(
+ const attachableDumps = freshDumps.filter(
(d) => d.ownership === 'ours' && d.crashKind !== 'non-crash',
- ).length;
+ );
+ const boundDump = (attachableDumps.find(arming) ?? attachableDumps[0])?.entry ?? null;
const rebootedBetweenSessions =
prevBootSessionUuid !== null &&
@@ -778,11 +1012,16 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
eventId,
kind: 'boot',
context: { dirtyShutdown: !dumpDriven, newMinidumps: newDumps.length },
- minidumpAvailable: ownedDumpCount > 0,
+ minidumpAvailable: boundDump !== null,
...(crashedAppVersion !== null ? { crashedAppVersion } : {}),
...(crashedAtMs !== null ? { crashedAt: new Date(crashedAtMs).toISOString() } : {}),
};
- if (armInvite(event)) {
+ if (
+ armInvite(event, {
+ state: 'settled',
+ dump: boundDump === null ? null : toBoundMinidump(boundDump),
+ })
+ ) {
armed = event;
deps.logger.info(
{
@@ -912,15 +1151,16 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
handleRenderProcessGone(details): void {
if (!isProcessCrashReason(details.reason)) return;
- const owned = newestOwnedMinidump();
+ const deathMs = deps.now().getTime();
+ const eventId = `crash:render:${deathMs}:${runtimeSeq++}`;
+ const scan = scanDeathWindow(deathMs);
deps.logger.warn(
{
event: 'crash-detection.render-process-gone',
+ eventId,
reason: details.reason,
exitCode: details.exitCode,
- foreignDumpsIgnored: owned.foreignSkipped,
- unreadableDumpsSkipped: owned.unknownSkipped,
- nonCrashDumpsSkipped: owned.nonCrashSkipped,
+ ...deathWindowFacts(scan),
...(details.processSnapshot === undefined
? {}
: { processSnapshot: details.processSnapshot }),
@@ -928,15 +1168,18 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
'renderer process died abnormally',
);
if (
- armInvite({
- eventId: `crash:render:${deps.now().getTime()}:${runtimeSeq++}`,
- kind: 'render-process-gone',
- context: {
- reason: details.reason,
- ...(details.exitCode !== undefined ? { exitCode: details.exitCode } : {}),
+ armRuntimeInvite(
+ {
+ eventId,
+ kind: 'render-process-gone',
+ context: {
+ reason: details.reason,
+ ...(details.exitCode !== undefined ? { exitCode: details.exitCode } : {}),
+ },
},
- minidumpAvailable: owned.entry !== null,
- })
+ deathMs,
+ scan.entry,
+ )
) {
tryDeliver();
}
@@ -944,43 +1187,48 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
handleChildProcessGone(details): void {
if (!isProcessCrashReason(details.reason)) return;
- const owned = newestOwnedMinidump();
const gpu = details.type === GPU_PROCESS_TYPE ? noteGpuCrash() : null;
+ const suppressInvite = gpu?.suppressInvite === true;
+ if (!suppressInvite && gpu !== null) clearDeclinedDeaths(GPU_DUMP_PROCESS_TYPE);
+ const deathMs = suppressInvite ? null : deps.now().getTime();
+ const eventId = deathMs === null ? null : `crash:child:${deathMs}:${runtimeSeq++}`;
+ const scan = deathMs === null ? null : scanDeathWindow(deathMs);
deps.logger.warn(
{
event: 'crash-detection.child-process-gone',
+ ...(eventId === null ? {} : { eventId }),
processType: details.type,
reason: details.reason,
exitCode: details.exitCode,
...(details.name === undefined ? {} : { name: details.name }),
- foreignDumpsIgnored: owned.foreignSkipped,
- unreadableDumpsSkipped: owned.unknownSkipped,
- nonCrashDumpsSkipped: owned.nonCrashSkipped,
+ ...(scan === null ? {} : deathWindowFacts(scan)),
...(details.processSnapshot === undefined
? {}
: { processSnapshot: details.processSnapshot }),
...(gpu === null ? {} : { gpuCrashesInWindow: gpu.countInWindow }),
- ...(gpu?.suppressInvite === true ? { invitationSuppressed: 'gpu-recoverable' } : {}),
+ ...(suppressInvite ? { invitationSuppressed: 'gpu-recoverable' } : {}),
},
'child process died abnormally',
);
- if (gpu?.suppressInvite === true) {
+ if (deathMs === null || eventId === null || scan === null) {
recordDeclinedDeath(GPU_DUMP_PROCESS_TYPE);
return;
}
- if (gpu !== null) clearDeclinedDeaths(GPU_DUMP_PROCESS_TYPE);
if (
- armInvite({
- eventId: `crash:child:${deps.now().getTime()}:${runtimeSeq++}`,
- kind: 'child-process-gone',
- context: {
- reason: details.reason,
- processType: details.type,
- ...(details.name !== undefined ? { name: details.name } : {}),
- ...(details.exitCode !== undefined ? { exitCode: details.exitCode } : {}),
+ armRuntimeInvite(
+ {
+ eventId,
+ kind: 'child-process-gone',
+ context: {
+ reason: details.reason,
+ processType: details.type,
+ ...(details.name !== undefined ? { name: details.name } : {}),
+ ...(details.exitCode !== undefined ? { exitCode: details.exitCode } : {}),
+ },
},
- minidumpAvailable: owned.entry !== null,
- })
+ deathMs,
+ scan.entry,
+ )
) {
tryDeliver();
}
@@ -1001,7 +1249,7 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
const baselineMs = Date.parse(store.minidumpBaselineAt);
store.declinedDeaths = store.declinedDeaths.filter((declined) => {
const at = epochMsOrNull(declined.at);
- return at !== null && at + DECLINED_DEATH_DUMP_MATCH_MS > baselineMs;
+ return at !== null && at + DEATH_DUMP_MATCH_MS > baselineMs;
});
persistStore('ack');
if (active?.event.eventId === eventId) {
@@ -1017,5 +1265,28 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
unknownSkipped: owned.unknownSkipped,
};
},
+
+ minidumpForCrashEvent(eventId: string): CrashEventMinidumpLookup {
+ const binding = settleInvitation(eventId, deps.now().getTime());
+ if (binding === undefined) return { status: 'omitted', reason: 'invitation-unbound' };
+ const bound = binding.dump;
+ if (bound === null) return { status: 'none-bound' };
+ const matches = listMinidumpEntries().filter(
+ (entry) => basename(entry.path) === bound.fileName,
+ );
+ const match = matches[0];
+ if (match === undefined) return { status: 'omitted', reason: 'bound-dump-missing' };
+ if (matches.length > 1) return { status: 'omitted', reason: 'bound-dump-ambiguous' };
+ if (match.sizeBytes !== bound.sizeBytes || match.mtimeMs !== bound.mtimeMs) {
+ return { status: 'omitted', reason: 'bound-dump-changed' };
+ }
+ const ownership = classifyDump(match.path);
+ if (ownership === 'unknown') return { status: 'omitted', reason: 'bound-dump-unreadable' };
+ if (ownership === 'foreign') return { status: 'omitted', reason: 'bound-dump-not-owned' };
+ if (crashKindOf(match.path) === 'non-crash') {
+ return { status: 'omitted', reason: 'bound-dump-non-crash' };
+ }
+ return { status: 'bound', path: match.path };
+ },
};
}
diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index 79bb71248..8b89db86d 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -4838,6 +4838,11 @@ function registerIpcHandlers() {
foreignSkipped: 0,
unknownSkipped: 0,
},
+ minidumpForCrashEvent: (eventId) =>
+ crashDetection?.minidumpForCrashEvent(eventId) ?? {
+ status: 'omitted',
+ reason: 'invitation-unbound',
+ },
screenshotPngBytes: () => bugReportScreenshots.get(event.sender.id)?.png ?? null,
onScreenshotStaged: (reportId, png) => {
const composedBy = event.sender.id;
diff --git a/packages/desktop/src/main/ipc/bug-report.test.ts b/packages/desktop/src/main/ipc/bug-report.test.ts
index 63670e065..e09b17779 100644
--- a/packages/desktop/src/main/ipc/bug-report.test.ts
+++ b/packages/desktop/src/main/ipc/bug-report.test.ts
@@ -6,6 +6,7 @@ import {
mkdirSync,
mkdtempSync,
readFileSync,
+ renameSync,
rmSync,
statSync,
symlinkSync,
@@ -2323,6 +2324,24 @@ describe('resolveMinidumpIntent', () => {
input: { requested: true, minidumpPath: '/dumps/a.dmp' },
expected: { reason: 'staging', zipEntry: 'extra/a.dmp' },
},
+ {
+ name: 'opted in, but the dump the invitation was bound to is gone',
+ input: {
+ requested: true,
+ minidumpPath: null,
+ unavailableReason: 'bound-dump-missing',
+ },
+ expected: { reason: 'bound-dump-missing' },
+ },
+ {
+ name: 'declining wins over a bound dump that is gone',
+ input: {
+ requested: false,
+ minidumpPath: null,
+ unavailableReason: 'bound-dump-missing',
+ },
+ expected: { reason: 'declined' },
+ },
];
for (const { name, input, expected } of cases) {
@@ -2647,6 +2666,7 @@ describe('handleBugReportCrashAck', () => {
{ kind: 'crash-ack' },
{ kind: 'crash-ack', eventId: '' },
{ kind: 'crash-ack', eventId: 42 },
+ { kind: 'crash-ack', eventId: 'x'.repeat(257) },
{ kind: 'ack', eventId: 'crash:render:1:0' },
null,
];
@@ -3437,3 +3457,300 @@ describe('createBugReportScreenshotHold — attachments', () => {
expect(hold.read('r1')).toBeNull();
});
});
+
+describe('handleBugReportCreate — the crash dump that armed the invitation', () => {
+ const FIRST_DUMP = '4f1b2c3d-0000-4000-8000-00000000000a.dmp';
+ const SECOND_DUMP = '4f1b2c3d-0000-4000-8000-00000000000b.dmp';
+
+ function makeBindingRig() {
+ const dir = makeTmpDir('ok-bugreport-binding-');
+ let clockMs = Date.parse('2026-07-10T00:00:00.000Z');
+ const appBundleRoot = join(dir, 'OpenKnowledge.app');
+ const mainModule = join(appBundleRoot, 'Contents', 'MacOS', 'OpenKnowledge');
+ const detectionDeps = {
+ sentinelPath: join(dir, 'sentinel.json'),
+ mainExitPath: join(dir, 'main-exit.json'),
+ ackStorePath: join(dir, 'crash-acks.json'),
+ crashDumpsDir: join(dir, 'dumps'),
+ appBundleRoot,
+ appVersion: '0.9.9',
+ platform: 'darwin' as const,
+ emit: () => true,
+ now: () => {
+ clockMs += 10_000;
+ return new Date(clockMs);
+ },
+ currentBootSessionUuid: () => 'boot-epoch-test',
+ mainThreadWatchdog: {
+ readPrevious: () => ({ kind: 'absent' }) as const,
+ readPreviousStall: () => ({ kind: 'absent' }) as const,
+ start: () => ({ stop: () => {} }),
+ },
+ logger: { info: () => {}, warn: () => {} },
+ };
+ const crashDump = (stamp: number) =>
+ buildMinidump([mainModule], { exceptionCode: 0xc000_0005, timeDateStamp: stamp });
+ const seed = (relPath: string, bytes: Buffer): string => {
+ const dumpPath = join(detectionDeps.crashDumpsDir, relPath);
+ mkdirSync(dirname(dumpPath), { recursive: true });
+ writeFileSync(dumpPath, bytes);
+ clockMs += 10_000;
+ const at = new Date(clockMs);
+ utimesSync(dumpPath, at, at);
+ return dumpPath;
+ };
+ const reportDeps = (
+ detection: ReturnType<typeof createCrashDetection>,
+ logger: BugReportCreateDeps['logger'],
+ ) =>
+ makeDeps({
+ newestMinidumpForReport: () => detection.newestMinidumpForReport(),
+ minidumpForCrashEvent: (eventId) => detection.minidumpForCrashEvent(eventId),
+ logger,
+ });
+ return {
+ detectionDeps,
+ crashDump,
+ foreignDump: buildMinidump(['/Applications/LibreOffice.app/Contents/MacOS/soffice']),
+ snapshotDump: buildMinidump([mainModule], { exceptionCode: 0x4350_7378 }),
+ seed,
+ reportDeps,
+ };
+ }
+
+ function crashedSessionThenReboot(rig: ReturnType<typeof makeBindingRig>, firstBytes: Buffer) {
+ createCrashDetection(rig.detectionDeps).detectBootCrash();
+ const firstPath = rig.seed(`pending/${FIRST_DUMP}`, firstBytes);
+ const session = createCrashDetection(rig.detectionDeps);
+ const invite = session.detectBootCrash();
+ if (invite === null) throw new Error('expected a boot invitation for the crashed session');
+ expect(invite.minidumpAvailable).toBe(true);
+ return { session, invite, firstPath };
+ }
+
+ function extraEntries(zipPath: string): string[] {
+ return listZipEntries(zipPath).filter((e) => e.startsWith('extra/'));
+ }
+
+ test('a report for the first crash attaches its dump even after a second crash wrote a newer one', async () => {
+ const rig = makeBindingRig();
+ const firstBytes = rig.crashDump(1);
+ const { session, invite } = crashedSessionThenReboot(rig, firstBytes);
+ rig.seed(`pending/${SECOND_DUMP}`, rig.crashDump(2));
+ session.handleRenderProcessGone({ reason: 'crashed' });
+ const recorder = makeLogRecorder();
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, recorder.logger), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: invite.eventId,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([`extra/${FIRST_DUMP}`]);
+ expect(readZipEntryBytes(result.zipPath, `extra/${FIRST_DUMP}`).equals(firstBytes)).toBe(true);
+ expect(recorder.intent()?.payload).toMatchObject({
+ reason: 'staging',
+ dumpSelection: 'crash-event',
+ crashEventId: invite.eventId,
+ });
+ expect(recorder.outcome()?.payload).toMatchObject({ attached: true, reason: 'attached' });
+ });
+
+ test('later foreign and snapshot dumps, and Crashpad filing the dump away, change nothing', async () => {
+ const rig = makeBindingRig();
+ const firstBytes = rig.crashDump(1);
+ const { session, invite, firstPath } = crashedSessionThenReboot(rig, firstBytes);
+ rig.seed('pending/soffice.dmp', rig.foreignDump);
+ rig.seed('pending/snapshot.dmp', rig.snapshotDump);
+ const filedPath = join(dirname(dirname(firstPath)), 'completed', FIRST_DUMP);
+ mkdirSync(dirname(filedPath), { recursive: true });
+ renameSync(firstPath, filedPath);
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, undefined), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: invite.eventId,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([`extra/${FIRST_DUMP}`]);
+ expect(readZipEntryBytes(result.zipPath, `extra/${FIRST_DUMP}`).equals(firstBytes)).toBe(true);
+ });
+
+ test('a bound dump Crashpad rotated away is omitted with its reason, never swapped for a newer one', async () => {
+ const rig = makeBindingRig();
+ const { session, invite, firstPath } = crashedSessionThenReboot(rig, rig.crashDump(1));
+ rig.seed(`pending/${SECOND_DUMP}`, rig.crashDump(2));
+ rmSync(firstPath);
+ const recorder = makeLogRecorder();
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, recorder.logger), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: invite.eventId,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([]);
+ const intent = recorder.intent();
+ expect(intent?.level).toBe('warn');
+ expect(intent?.payload).toMatchObject({
+ requested: true,
+ minidumpAvailable: false,
+ reason: 'bound-dump-missing',
+ dumpSelection: 'crash-event',
+ crashEventId: invite.eventId,
+ });
+ expect(recorder.outcome()).toBeUndefined();
+ const serialized = `${JSON.stringify(intent?.payload)} ${intent?.message}`;
+ expect(serialized).not.toContain(FIRST_DUMP);
+ expect(serialized).not.toContain(SECOND_DUMP);
+ });
+
+ test('a bound dump that can no longer be read is omitted as unreadable, not as foreign', async () => {
+ const rig = makeBindingRig();
+ const firstBytes = rig.crashDump(1);
+ const { session, invite, firstPath } = crashedSessionThenReboot(rig, firstBytes);
+ const { mtime } = statSync(firstPath);
+ writeFileSync(firstPath, Buffer.alloc(firstBytes.length, 0x41));
+ utimesSync(firstPath, mtime, mtime);
+ const recorder = makeLogRecorder();
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, recorder.logger), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: invite.eventId,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([]);
+ const intent = recorder.intent();
+ expect(intent?.level).toBe('warn');
+ expect(intent?.payload).toMatchObject({
+ requested: true,
+ minidumpAvailable: false,
+ reason: 'bound-dump-unreadable',
+ dumpSelection: 'crash-event',
+ crashEventId: invite.eventId,
+ });
+ expect(intent?.payload).not.toHaveProperty('foreignDumpsIgnored');
+ expect(intent?.payload).not.toHaveProperty('unreadableDumpsSkipped');
+ });
+
+ test('the omission reason is inside the bundle it explains', async () => {
+ const rig = makeBindingRig();
+ const { session, invite, firstPath } = crashedSessionThenReboot(rig, rig.crashDump(1));
+ rmSync(firstPath);
+ const userLogsDir = makeTmpDir();
+ const logPath = join(userLogsDir, 'desktop.2026-01-01.log');
+ const write = (level: 'info' | 'warn') => (payload: object, message: string) => {
+ appendFileSync(logPath, `${JSON.stringify({ level, ...payload, msg: message })}\n`);
+ };
+ const deps = {
+ ...rig.reportDeps(session, { info: write('info'), warn: write('warn') }),
+ userLogsDir,
+ };
+
+ const result = await handleBugReportCreate(deps, {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: invite.eventId,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ const decisions = readZipEntry(result.zipPath, 'logs/desktop.2026-01-01.log')
+ .split('\n')
+ .filter((l) => l.includes('bug-report.minidump-decision'))
+ .map((l) => JSON.parse(l) as Record<string, unknown>);
+ expect(decisions).toEqual([
+ expect.objectContaining({ phase: 'intent', reason: 'bound-dump-missing', level: 'warn' }),
+ ]);
+ });
+
+ test('a clean quit arms nothing, and a report naming an unknown crash attaches nothing', async () => {
+ const rig = makeBindingRig();
+ const sessionA = createCrashDetection(rig.detectionDeps);
+ sessionA.detectBootCrash();
+ sessionA.markCleanQuit();
+ const session = createCrashDetection(rig.detectionDeps);
+ expect(session.detectBootCrash()).toBeNull();
+ rig.seed(`pending/${SECOND_DUMP}`, rig.crashDump(2));
+ const recorder = makeLogRecorder();
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, recorder.logger), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: 'boot:dump:1751871600000',
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([]);
+ expect(recorder.intent()?.payload.reason).toBe('invitation-unbound');
+ });
+
+ test('a report the user opened themselves still takes the newest dump this app owns', async () => {
+ const rig = makeBindingRig();
+ const { session } = crashedSessionThenReboot(rig, rig.crashDump(1));
+ const secondBytes = rig.crashDump(2);
+ rig.seed(`pending/${SECOND_DUMP}`, secondBytes);
+ const recorder = makeLogRecorder();
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, recorder.logger), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([`extra/${SECOND_DUMP}`]);
+ expect(readZipEntryBytes(result.zipPath, `extra/${SECOND_DUMP}`).equals(secondBytes)).toBe(
+ true,
+ );
+ expect(recorder.intent()?.payload).toMatchObject({ dumpSelection: 'newest' });
+ });
+
+ test('a recovery with no dump offers none, and a dump written afterwards is not attached', async () => {
+ const rig = makeBindingRig();
+ createCrashDetection(rig.detectionDeps).detectBootCrash();
+ const session = createCrashDetection(rig.detectionDeps);
+ const invite = session.detectBootCrash();
+ if (invite === null) throw new Error('expected a dirty-shutdown invitation');
+ expect(invite.minidumpAvailable).toBe(false);
+ rig.seed(`pending/${SECOND_DUMP}`, rig.crashDump(2));
+ const recorder = makeLogRecorder();
+
+ const result = await handleBugReportCreate(rig.reportDeps(session, recorder.logger), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId: invite.eventId,
+ });
+
+ if (!result.ok) throw new Error(`expected ok, got: ${result.error}`);
+ expect(extraEntries(result.zipPath)).toEqual([]);
+ expect(recorder.intent()?.payload).toMatchObject({
+ reason: 'none-available',
+ dumpSelection: 'crash-event',
+ });
+ });
+
+ test('a malformed crash event id is refused as invalid-request', async () => {
+ for (const crashEventId of ['', 42, 'x'.repeat(257)]) {
+ const result = await handleBugReportCreate(makeDeps(), {
+ kind: 'create',
+ level: 'standard',
+ includeCrashDump: true,
+ crashEventId,
+ } as unknown as OkBugReportCreateRequest);
+
+ expect(result).toEqual({ ok: false, error: 'invalid-request' });
+ }
+ });
+});
diff --git a/packages/desktop/src/main/ipc/bug-report.ts b/packages/desktop/src/main/ipc/bug-report.ts
index 3ecd916af..861c1f525 100644
--- a/packages/desktop/src/main/ipc/bug-report.ts
+++ b/packages/desktop/src/main/ipc/bug-report.ts
@@ -42,7 +42,11 @@ import {
stageAgentChatTranscript,
} from '../bug-report-agent-chat.ts';
import { type BugReportSendTrace, beginSendTrace } from '../bug-report-trace.ts';
-import type { MinidumpReportLookup } from '../crash-detection.ts';
+import type {
+ BoundMinidumpOmission,
+ CrashEventMinidumpLookup,
+ MinidumpReportLookup,
+} from '../crash-detection.ts';
import { logIpcError } from '../ipc-log.ts';
import {
readMinidumpAccessibilityMode,
@@ -59,6 +63,7 @@ export interface OkBugReportCreateRequest {
includeScreenshot?: boolean;
attachments?: OkBugReportAttachmentInput[];
agentChatThreadId?: string;
+ crashEventId?: string;
}
interface OkBugReportCaptureScreenshotRequest {
@@ -115,6 +120,7 @@ export interface BugReportCreateDeps {
outputPath?: string;
userLogsDir?: string;
newestMinidumpForReport?: () => MinidumpReportLookup;
+ minidumpForCrashEvent?: (eventId: string) => CrashEventMinidumpLookup;
screenshotPngBytes?: () => Buffer | null;
logger?: BundleLogger;
flushLogger?: () => void;
@@ -132,6 +138,12 @@ export interface StagedAttachment {
const MAX_NOTE_LENGTH = 32_768;
+const MAX_CRASH_EVENT_ID_LENGTH = 256;
+
+function isCrashEventId(value: unknown): value is string {
+ return typeof value === 'string' && value !== '' && value.length <= MAX_CRASH_EVENT_ID_LENGTH;
+}
+
function isValidNote(note: unknown): boolean {
return note === undefined || (typeof note === 'string' && note.length <= MAX_NOTE_LENGTH);
}
@@ -177,7 +189,8 @@ function isCreateRequest(request: unknown): request is OkBugReportCreateRequest
(r.includeCrashDump === undefined || typeof r.includeCrashDump === 'boolean') &&
(r.includeScreenshot === undefined || typeof r.includeScreenshot === 'boolean') &&
isValidAttachments(r.attachments) &&
- (r.agentChatThreadId === undefined || isAgentChatThreadId(r.agentChatThreadId))
+ (r.agentChatThreadId === undefined || isAgentChatThreadId(r.agentChatThreadId)) &&
+ (r.crashEventId === undefined || isCrashEventId(r.crashEventId))
);
}
@@ -186,7 +199,8 @@ type MinidumpAttachReason =
| 'declined'
| 'not-offered'
| 'none-available'
- | 'stage-failed';
+ | 'stage-failed'
+ | BoundMinidumpOmission;
const NO_MINIDUMP_LOOKUP: MinidumpReportLookup = {
path: null,
@@ -206,10 +220,11 @@ export type MinidumpIntent =
export function resolveMinidumpIntent(input: {
requested: boolean | undefined;
minidumpPath: string | null;
+ unavailableReason?: BoundMinidumpOmission;
}): MinidumpIntent {
if (input.requested === undefined) return { reason: 'not-offered' };
if (input.requested === false) return { reason: 'declined' };
- if (input.minidumpPath === null) return { reason: 'none-available' };
+ if (input.minidumpPath === null) return { reason: input.unavailableReason ?? 'none-available' };
return { reason: 'staging', zipEntry: `extra/${basename(input.minidumpPath)}` };
}
@@ -221,6 +236,55 @@ export function resolveMinidumpAttachment(
return { attached: false, reason: 'stage-failed' };
}
+type MinidumpSelectionFacts =
+ | { dumpSelection: 'crash-event'; crashEventId: string }
+ | { dumpSelection: 'newest'; foreignDumpsIgnored: number; unreadableDumpsSkipped: number };
+
+type MinidumpSelection =
+ | { status: 'not-requested' }
+ | { status: 'selected'; path: string; facts: MinidumpSelectionFacts }
+ | { status: 'unavailable'; reason?: BoundMinidumpOmission; facts: MinidumpSelectionFacts };
+
+function selectMinidump(
+ deps: BugReportCreateDeps,
+ request: OkBugReportCreateRequest,
+): MinidumpSelection {
+ if (request.includeCrashDump !== true) return { status: 'not-requested' };
+ if (request.crashEventId !== undefined) {
+ const facts: MinidumpSelectionFacts = {
+ dumpSelection: 'crash-event',
+ crashEventId: request.crashEventId,
+ };
+ const bound: CrashEventMinidumpLookup = deps.minidumpForCrashEvent?.(request.crashEventId) ?? {
+ status: 'omitted',
+ reason: 'invitation-unbound',
+ };
+ switch (bound.status) {
+ case 'bound':
+ return { status: 'selected', path: bound.path, facts };
+ case 'none-bound':
+ return { status: 'unavailable', facts };
+ case 'omitted':
+ return { status: 'unavailable', reason: bound.reason, facts };
+ default:
+ return assertNeverCrashEventMinidumpLookup(bound);
+ }
+ }
+ const lookup = deps.newestMinidumpForReport?.() ?? NO_MINIDUMP_LOOKUP;
+ const facts: MinidumpSelectionFacts = {
+ dumpSelection: 'newest',
+ foreignDumpsIgnored: lookup.foreignSkipped,
+ unreadableDumpsSkipped: lookup.unknownSkipped,
+ };
+ return lookup.path === null
+ ? { status: 'unavailable', facts }
+ : { status: 'selected', path: lookup.path, facts };
+}
+
+function assertNeverCrashEventMinidumpLookup(value: never): never {
+ throw new Error(`unhandled crash-event minidump lookup: ${JSON.stringify(value)}`);
+}
+
function recordMinidumpDecision(
logger: BundleLogger | undefined,
level: 'info' | 'warn',
@@ -334,14 +398,13 @@ export async function handleBugReportCreate(
});
return { ok: false, error: 'invalid-request' };
}
- const minidumpLookup =
- request.includeCrashDump === true
- ? (deps.newestMinidumpForReport?.() ?? NO_MINIDUMP_LOOKUP)
- : NO_MINIDUMP_LOOKUP;
- const minidumpPath = minidumpLookup.path;
+ const selection = selectMinidump(deps, request);
+ const minidumpPath = selection.status === 'selected' ? selection.path : null;
+ const unavailableReason = selection.status === 'unavailable' ? selection.reason : undefined;
const intent = resolveMinidumpIntent({
requested: request.includeCrashDump,
minidumpPath,
+ ...(unavailableReason !== undefined ? { unavailableReason } : {}),
});
const screenshotBytes =
request.includeScreenshot === true ? (deps.screenshotPngBytes?.() ?? null) : null;
@@ -360,15 +423,10 @@ export async function handleBugReportCreate(
const dumpDisplayLock = minidumpPath === null ? null : readMinidumpDisplayLockState(minidumpPath);
const decisionFacts = {
+ ...(selection.status === 'not-requested' ? {} : selection.facts),
event: 'bug-report.minidump-decision',
- requested: request.includeCrashDump === true,
- ...(request.includeCrashDump === true
- ? {
- minidumpAvailable: minidumpPath !== null,
- foreignDumpsIgnored: minidumpLookup.foreignSkipped,
- unreadableDumpsSkipped: minidumpLookup.unknownSkipped,
- }
- : {}),
+ requested: selection.status !== 'not-requested',
+ ...(selection.status === 'not-requested' ? {} : { minidumpAvailable: minidumpPath !== null }),
...(dumpSizeBytes !== undefined ? { sizeBytes: dumpSizeBytes } : {}),
...(dumpAccessibilityMode === null
? {}
@@ -384,11 +442,14 @@ export async function handleBugReportCreate(
}),
};
+ const boundDumpOmitted = unavailableReason !== undefined;
recordMinidumpDecision(
deps.logger,
- 'info',
+ boundDumpOmitted ? 'warn' : 'info',
{ ...decisionFacts, phase: 'intent', reason: intent.reason },
- 'bug-report: crash-dump decision recorded before collection',
+ boundDumpOmitted
+ ? 'bug-report: the crash dump this report was invited for is no longer attachable; the report goes without it'
+ : 'bug-report: crash-dump decision recorded before collection',
);
try {
deps.flushLogger?.();
@@ -1361,7 +1422,7 @@ export interface BugReportCrashAckDeps {
function isCrashAckRequest(request: unknown): request is OkBugReportCrashAckRequest {
if (typeof request !== 'object' || request === null) return false;
const r = request as Record<string, unknown>;
- return r.kind === 'crash-ack' && typeof r.eventId === 'string' && r.eventId !== '';
+ return r.kind === 'crash-ack' && isCrashEventId(r.eventId);
}
export function handleBugReportCrashAck(
diff --git a/packages/desktop/src/preload/bridge-forwarding.test.ts b/packages/desktop/src/preload/bridge-forwarding.test.ts
index a5bcf4ad7..5ddfa9bbd 100644
--- a/packages/desktop/src/preload/bridge-forwarding.test.ts
+++ b/packages/desktop/src/preload/bridge-forwarding.test.ts
@@ -197,6 +197,7 @@ describe('preload bugReport.create marshalling', () => {
includeCrashDump: true,
includeScreenshot: true,
attachments: [{ contentType: 'image/png', bytes: new Uint8Array([1, 2, 3]) }],
+ crashEventId: 'boot:dump:1751871600000',
};
await bridge.bugReport.create(request);
diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.ts
index 78870809c..c17ff4a97 100644
--- a/packages/desktop/src/preload/index.ts
+++ b/packages/desktop/src/preload/index.ts
@@ -570,6 +570,7 @@ const bridge: OkDesktopBridge = {
includeScreenshot: request.includeScreenshot,
attachments: request.attachments,
agentChatThreadId: request.agentChatThreadId,
+ crashEventId: request.crashEventId,
}) as Promise<OkBugReportCreateResult>,
captureScreenshot: () =>
invoke('ok:bug-report:dispatch', {