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 2581fce

Browse filesBrowse files
joyeecheungRafaelGSS
authored andcommitted
bootstrap: improve snapshot unsupported builtin warnings
- Only emit warning when the snapshot is built. In general built-ins loaded after the snapshot is built should work as usual. - Clarify what the warning means PR-URL: #50944 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent fc55032 commit 2581fce
Copy full SHA for 2581fce

File tree

Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Collapse file

‎lib/internal/main/mksnapshot.js‎

Copy file name to clipboardExpand all lines: lib/internal/main/mksnapshot.js
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const {
1919
const { isExperimentalSeaWarningNeeded } = internalBinding('sea');
2020

2121
const { emitExperimentalWarning } = require('internal/util');
22-
22+
const { emitWarningSync } = require('internal/process/warning');
2323
const {
2424
getOptionValue,
2525
} = require('internal/options');
@@ -29,6 +29,7 @@ const {
2929
namespace: {
3030
addSerializeCallback,
3131
addDeserializeCallback,
32+
isBuildingSnapshot,
3233
},
3334
} = require('internal/v8/startup_snapshot');
3435

@@ -119,10 +120,18 @@ function requireForUserSnapshot(id) {
119120
err.code = 'MODULE_NOT_FOUND';
120121
throw err;
121122
}
122-
if (!supportedInUserSnapshot(normalizedId)) {
123+
if (isBuildingSnapshot() && !supportedInUserSnapshot(normalizedId)) {
123124
if (!warnedModules.has(normalizedId)) {
124-
process.emitWarning(
125-
`built-in module ${id} is not yet supported in user snapshots`);
125+
// Emit the warning synchronously in case we don't get to process
126+
// the tick and print it before the unsupported built-in causes a
127+
// crash.
128+
emitWarningSync(
129+
`It's not yet fully verified whether built-in module "${id}" ` +
130+
'works in user snapshot builder scripts.\n' +
131+
'It may still work in some cases, but in other cases certain ' +
132+
'run-time states may be out-of-sync after snapshot deserialization.\n' +
133+
'To request support for the module, use the Node.js issue tracker: ' +
134+
'https://github.com/nodejs/node/issues');
126135
warnedModules.add(normalizedId);
127136
}
128137
}

0 commit comments

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