Skip to content

Commit 96036ef

Browse files
joyeecheungBethGriggs
authored andcommitted
lib: do not register DOMException in a module
Instead of registering it in a global scope of a native module and expecting that it only gets evaluated when the module is actually compiled and run and will not be evaluated because the module can be cached, directly register the DOMException constructor onto Environment during bootstrap for clarity, since this is a side effect that has to happen during bootstrap. PR-URL: #24708 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent dacdd01 commit 96036ef

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/internal/bootstrap/node.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@
434434

435435
function setupDOMException() {
436436
// Registers the constructor with C++.
437-
NativeModule.require('internal/domexception');
437+
const DOMException = NativeModule.require('internal/domexception');
438+
const { registerDOMException } = internalBinding('messaging');
439+
registerDOMException(DOMException);
438440
}
439441

440442
function setupInspector(originalConsole, wrappedConsole) {

lib/internal/domexception.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const { registerDOMException } = internalBinding('messaging');
43
const { ERR_INVALID_THIS } = require('internal/errors').codes;
54

65
const internalsMap = new WeakMap();
@@ -85,5 +84,3 @@ for (const [name, codeName, value] of [
8584
}
8685

8786
module.exports = DOMException;
88-
89-
registerDOMException(DOMException);

0 commit comments

Comments
 (0)