Skip to content

Commit 976065d

Browse files
committed
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 2931c50 commit 976065d

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

lib/internal/bootstrap/node.js

Lines changed: 3 additions & 1 deletion
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

Lines changed: 0 additions & 3 deletions
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)