Skip to content

Commit 0cdeb63

Browse files
committed
experiment: trace fatal errors with the destroyed-window guard (do not merge)
1 parent 91e5f02 commit 0cdeb63

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎.github/workflows/desktop-e2e.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
name: e2e (${{ matrix.shard }}/${{ strategy.job-total }})
108108
if: github.event_name != 'schedule' && github.event_name != 'push'
109109
runs-on: macos-26
110-
timeout-minutes: 30
110+
timeout-minutes: 60
111111
strategy:
112112
fail-fast: false
113113
matrix:
@@ -163,7 +163,7 @@ jobs:
163163

164164
- name: Run Playwright _electron smoke suite
165165
working-directory: apps/desktop
166-
run: bun run ../../scripts/desktop-e2e.ts ${{ matrix.shard }}/${{ strategy.job-total }}
166+
run: bunx playwright test e2e/terminal-cancel.spec.ts --grep "the launch after|survives a quit" --repeat-each=30 --reporter=line,json
167167
env:
168168
PLAYWRIGHT_JSON_OUTPUT_FILE: test-results/desktop-smoke.json
169169

@@ -175,6 +175,15 @@ jobs:
175175
path: apps/desktop/test-results
176176
retention-days: 7
177177

178+
- name: Upload fatal trace
179+
if: always()
180+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
181+
with:
182+
name: fatal-trace-${{ matrix.shard }}
183+
path: /tmp/sim-fatal-trace.log
184+
if-no-files-found: ignore
185+
retention-days: 7
186+
178187
- name: Upload smoke coverage and timings
179188
if: always()
180189
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2

‎apps/desktop/src/main/observability.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ export interface MainProcessFailureObserverDeps {
7474

7575
const FAILURE_DEDUPE_MS = 5_000
7676

77+
function experimentTrace(line: string): void {
78+
try {
79+
appendFileSync(
80+
'/tmp/sim-fatal-trace.log',
81+
`[fatal-trace pid=${process.pid} ${new Date().toISOString()}] ${line}\n`
82+
)
83+
} catch {}
84+
}
85+
7786
/**
7887
* Records native child-process failures and gives a fatal main-process error a
7988
* single native recovery surface. Error text is deliberately excluded from
@@ -121,6 +130,9 @@ export function installMainProcessFailureObservers({
121130
name: 'main_unhandled_rejection' | 'main_uncaught_exception',
122131
value: unknown
123132
): void => {
133+
experimentTrace(
134+
`fatal ${name}\n${value instanceof Error ? `${value.name}: ${value.message}\n${value.stack}` : String(value)}`
135+
)
124136
if (fatalRecoveryOpen) return
125137
fatalRecoveryOpen = true
126138
events.record(name, { valueType: value instanceof Error ? 'Error' : typeof value })
@@ -171,6 +183,9 @@ export function installMainProcessFailureObservers({
171183
app.on('child-process-gone', onChildProcessGone)
172184
app.on('before-quit', answerOpenPromptAsQuit)
173185
app.on('will-quit', onWillQuit)
186+
app.on('before-quit', () => experimentTrace('before-quit'))
187+
app.on('quit', () => experimentTrace('quit'))
188+
experimentTrace('observers installed')
174189
processSource.on('unhandledRejection', onUnhandledRejection)
175190
processSource.on('uncaughtException', onUncaughtException)
176191
}

0 commit comments

Comments
 (0)