Skip to content

Commit eab981e

Browse files
joyeecheungBridgeAR
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 <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1743568 commit eab981e

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
@@ -566,7 +566,9 @@
566566

567567
function setupDOMException() {
568568
// Registers the constructor with C++.
569-
NativeModule.require('internal/domexception');
569+
const DOMException = NativeModule.require('internal/domexception');
570+
const { registerDOMException } = internalBinding('messaging');
571+
registerDOMException(DOMException);
570572
}
571573

572574
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)