Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 391aeb1

Browse filesBrowse files
aduh95targos
authored andcommitted
module: fix crash when built-in module export a default key
PR-URL: #51481 Fixes: #51480 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
1 parent d3b7805 commit 391aeb1
Copy full SHA for 391aeb1

File tree

Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/bootstrap/realm.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/realm.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ class BuiltinModule {
350350
const url = `node:${this.id}`;
351351
const builtin = this;
352352
const exportsKeys = ArrayPrototypeSlice(this.exportKeys);
353-
ArrayPrototypePush(exportsKeys, 'default');
353+
if (!ArrayPrototypeIncludes(exportsKeys, 'default')) {
354+
ArrayPrototypePush(exportsKeys, 'default');
355+
}
354356
this.module = new ModuleWrap(
355357
url, undefined, exportsKeys,
356358
function() {
Collapse file
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('node:assert');
4+
5+
process.default = 1;
6+
import('node:process').then(common.mustCall((processModule) => {
7+
assert.strictEqual(processModule.default.default, 1);
8+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.