Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: improve snapshot unsupported builtin warnings #50944

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/internal/main/mksnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
const { isExperimentalSeaWarningNeeded } = internalBinding('sea');

const { emitExperimentalWarning } = require('internal/util');

const { emitWarningSync } = require('internal/process/warning');
const {
getOptionValue,
} = require('internal/options');
Expand All @@ -29,6 +29,7 @@ const {
namespace: {
addSerializeCallback,
addDeserializeCallback,
isBuildingSnapshot,
},
} = require('internal/v8/startup_snapshot');

Expand Down Expand Up @@ -119,10 +120,18 @@ function requireForUserSnapshot(id) {
err.code = 'MODULE_NOT_FOUND';
throw err;
}
if (!supportedInUserSnapshot(normalizedId)) {
if (isBuildingSnapshot() && !supportedInUserSnapshot(normalizedId)) {
if (!warnedModules.has(normalizedId)) {
process.emitWarning(
`built-in module ${id} is not yet supported in user snapshots`);
// Emit the warning synchronously in case we don't get to process
// the tick and print it before the unsupported built-in causes a
// crash.
emitWarningSync(
joyeecheung marked this conversation as resolved.
Show resolved Hide resolved
joyeecheung marked this conversation as resolved.
Show resolved Hide resolved
`It's not yet fully verified whether built-in module "${id}" ` +
'works in user snapshot builder scripts.\n' +
'It may still work in some cases, but in other cases certain ' +
'run-time states may be out-of-sync after snapshot deserialization.\n' +
'To request support for the module, use the Node.js issue tracker: ' +
'https://github.com/nodejs/node/issues');
warnedModules.add(normalizedId);
}
}
Expand Down