Skip to content

fix: handle createWindow() rejection in import-meta test fixture - #51441

Merged
dsanders11 merged 2 commits into
mainfrom
fix/esm-import-meta-test-flake
May 4, 2026
Merged

dsanders11 merged 2 commits into
mainfrom
fix/esm-import-meta-test-flake

Conversation

@ckerr

@ckerr ckerr commented May 1, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Potential fix for an esm-spec.ts test flake in "should use import.meta callback handling from Node.js for Node.js modules".

The import-meta fixture's createWindow() is async but was called fire-and-forget. If loadFile() or executeJavaScript() rejects transiently, process.exit() is never reached. On macOS the process hangs indefinitely because 'window-all-closed' had a process.platform !== 'darwin' guard that skipped app.quit().

It's hard to prove that a test flake is fixed, but this theory matches the behavior and is worthwhile as a spec cleanup either way. edit: only a cleanup, unfortunately. The CI failure is still there.

Sample CI failure:

2026-05-01T20:20:27.6600380Z Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/esm-spec.ts)
2026-05-01T20:20:27.6603310Z     at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
2026-05-01T20:20:27.6605350Z     at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
2026-05-01T20:20:27.6607200Z Retrying test (1/3)...
2026-05-01T20:20:57.6695430Z Failure in test: "esm renderer process nodeIntegration without context isolation should use import.meta callback handling from Node.js for Node.js modules"
2026-05-01T20:20:57.6702120Z Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/esm-spec.ts)
2026-05-01T20:20:57.6704730Z     at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
2026-05-01T20:20:57.6706870Z     at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
2026-05-01T20:20:57.6708420Z Retrying test (2/3)...
2026-05-01T20:21:27.6770530Z Failure in test: "esm renderer process nodeIntegration without context isolation should use import.meta callback handling from Node.js for Node.js modules"
2026-05-01T20:21:27.6774450Z Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/esm-spec.ts)
2026-05-01T20:21:27.6777380Z     at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
2026-05-01T20:21:27.6779620Z     at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10) 
2026-05-01T20:21:27.6781470Z Retrying test (3/3)...
2026-05-01T20:21:57.6889880Z not ok 912 esm renderer process nodeIntegration without context isolation should use import.meta callback handling from Node.js for Node.js modules
2026-05-01T20:21:57.6893720Z   Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/esm-spec.ts)
2026-05-01T20:21:57.6896920Z   Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/esm-spec.ts)
2026-05-01T20:21:57.6899550Z       at listOnTimeout (node:internal/timers:605:17)
2026-05-01T20:21:57.6900560Z       at processTimers (node:internal/timers:541:7)
...
2026-05-01T21:06:04.6242770Z ##[error]The action 'Run Electron Tests' has timed out after 60 minutes.

Complements #51432. This PR is "try to fix the test", and 51432 is "try to fix the runner to not hang on a failed test".

Checklist

Release Notes

Notes: none.

ckerr added 2 commits May 1, 2026 17:12
Remove macOS dock handling boilerplate code from electron-quick-start.
This test fixture is a short-lived process that calls process.exit()
on completion, so we don't need it.
The createWindow() promise was fire-and-forget. If loadFile() or
executeJavaScript() rejects transiently, process.exit() was never
called and the process would hang.
@ckerr ckerr added semver/patch backwards-compatible bug fixes target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels May 1, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 1, 2026
@ckerr ckerr mentioned this pull request May 1, 2026
6 tasks done
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label May 2, 2026
@dsanders11
dsanders11 merged commit 3860a98 into main May 4, 2026
298 of 309 checks passed
@dsanders11
dsanders11 deleted the fix/esm-import-meta-test-flake branch May 4, 2026 13:48
@release-clerk

release-clerk Bot commented May 4, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #51468

@trop trop Bot added the in-flight/42-x-y label May 4, 2026
@trop trop Bot removed the target/42-x-y PR should also be added to the "42-x-y" branch. label May 4, 2026
@trop

trop Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #51469

@trop

trop Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "40-x-y", please check out #51470

@trop trop Bot added in-flight/41-x-y in-flight/40-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed target/41-x-y PR should also be added to the "41-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. in-flight/41-x-y in-flight/42-x-y labels May 4, 2026
@trop trop Bot added merged/40-x-y PR was merged to the "40-x-y" branch. and removed in-flight/40-x-y labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants