Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
joyeecheung committed Nov 27, 2023
commit bcf7cb39d7ad085930154017d0fdc96e1162d047
14 changes: 10 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,15 @@ 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`);
emitWarningSync(
Comment thread
joyeecheung marked this conversation as resolved.
Comment thread
joyeecheung marked this conversation as 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