MarshallOfSound

#53493: fix: don't throw when adding or removing console-message listeners on a destroyed WebContents

Merged
Created: Sep 3, 2026, 7:27:52 PM
Merged: Sep 3, 2026, 8:28:08 PM
5 comments
Target: main

#53115 added newListener / removeListener hooks that call _setConsoleMessageObserved() without checking isDestroyed(). EventEmitter emits those synchronously, so on a destroyed WebContents the native Object has been destroyed error escapes from on('console-message'), removeListener('console-message') and removeAllListeners(), aborting teardown sweeps partway through.

  • Skip the native call in both hooks once the WebContents is destroyed; JS listener bookkeeping is unchanged.
  • Specs for add, remove and removeAllListeners on a destroyed WebContents.

Notes: Fixed webContents.on(), removeListener() and removeAllListeners() throwing "Object has been destroyed" for console-message listeners after the WebContents was destroyed.

Backports

42-x-y
Merged
PR Number
#53497
Merged At
Sep 3, 2026, 9:49:10 PM
Released In
Not yet
Release Date
Not yet
43-x-y
Merged
PR Number
#53496
Merged At
Sep 3, 2026, 9:48:13 PM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#53494
Merged At
Sep 3, 2026, 9:45:19 PM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#53495
Merged At
Sep 4, 2026, 12:11:52 AM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron