Skip to content

test: fix race in reentrant loadURL() ready-to-commit test - #51315

Merged
ckerr merged 1 commit into
mainfrom
fix/flaky-loadurl-reentrancy-test
Apr 26, 2026
Merged

ckerr merged 1 commit into
mainfrom
fix/flaky-loadurl-reentrancy-test

Conversation

@ckerr

@ckerr ckerr commented Apr 25, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Fix fails if loadurl is called after the navigation is ready to commit by using a done() callback to ensure the test waits for did-fail-load. Previously, the test would return immediately and call afterEach(closeAllWindows), potentially destroying the window while navigation was in flight.

This use of done() here matches how the nearby tests work.

Sample test failure:

Unhandled exception in main spec runner: TypeError: Object has been destroyed
not ok 390 webContents module loadURL() promise API "after each" hook: closeAllWindows in "loadURL() promise API"
    at BrowserWindow.n.loadURL (node:electron/js2c/browser_init:2:20276)
  done() called multiple times in hook <webContents module loadURL() promise API "after each" hook: closeAllWindows in "loadURL() promise API"> of file D:\a\_work\1\b\src\electron\spec\api-web-contents-spec.ts; in addition, done() received error: TypeError: Object has been destroyed
    at WebContents.<anonymous> (D:\a\_work\1\b\src\electron\spec\api-web-contents-spec.ts:563:11)
      at BrowserWindow.n.loadURL (node:electron/js2c/browser_init:2:20276)
    at Object.onceWrapper (node:events:631:26)
      at WebContents.<anonymous> (D:\a\_work\1\b\src\electron\spec\api-web-contents-spec.ts:563:11)
    at WebContents.emit (node:events:509:28)
      at Object.onceWrapper (node:events:631:26)
      at WebContents.emit (node:events:509:28) {
    uncaught: true
  }
  Error: done() called multiple times in hook <webContents module loadURL() promise API "after each" hook: closeAllWindows in "loadURL() promise API"> of file D:\a\_work\1\b\src\electron\spec\api-web-contents-spec.ts; in addition, done() received error: TypeError: Object has been destroyed
      at BrowserWindow.n.loadURL (node:electron/js2c/browser_init:2:20276)
      at WebContents.<anonymous> (electron\spec\api-web-contents-spec.ts:563:11)
      at Object.onceWrapper (node:events:631:26)
      at WebContents.emit (node:events:509:28) {
    uncaught: true
  }
      at process.emit (node:events:521:24)
      at process.emit (electron\node_modules\source-map-support\source-map-support.js:495:21)
      at process._fatalException (node:internal/process/execution:159:25)
✗ Electron tests failed with code 0x1.

Checklist

Release Notes

Notes: none.

Fix 'fails if loadurl is called after the navigation is ready to commit'
by using a done() callback to ensure the test waits for did-fail-load
before exiting.

Previously, the test would return and call afterEach(closeAllWindows),
potentially destroying the window while navigation was in flight.
@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 Apr 25, 2026
@ckerr ckerr changed the title test: fix race in reentrant loadURL() ready-to-commit test test: fix race in reentrant loadURL() ready-to-commit test Apr 25, 2026
@ckerr
ckerr merged commit ded39ee into main Apr 26, 2026
135 of 137 checks passed
@ckerr
ckerr deleted the fix/flaky-loadurl-reentrancy-test branch April 26, 2026 14:40
@release-clerk

release-clerk Bot commented Apr 26, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

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

@trop trop Bot removed the target/40-x-y PR should also be added to the "40-x-y" branch. label Apr 26, 2026
@trop

trop Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

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

@trop trop Bot added in-flight/41-x-y in-flight/42-x-y 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. and removed 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. in-flight/40-x-y in-flight/41-x-y in-flight/42-x-y labels Apr 26, 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