| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fc55032 commit 2581fce
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ const { | |||
| 19 | 19 | const { isExperimentalSeaWarningNeeded } = internalBinding('sea'); | |
| 20 | 20 | ||
| 21 | 21 | const { emitExperimentalWarning } = require('internal/util'); | |
| 22 | - | ||
| 22 | + const { emitWarningSync } = require('internal/process/warning'); | ||
| 23 | 23 | const { | |
| 24 | 24 | getOptionValue, | |
| 25 | 25 | } = require('internal/options'); | |
@@ -29,6 +29,7 @@ const { | |||
| 29 | 29 | namespace: { | |
| 30 | 30 | addSerializeCallback, | |
| 31 | 31 | addDeserializeCallback, | |
| 32 | + isBuildingSnapshot, | ||
| 32 | 33 | }, | |
| 33 | 34 | } = require('internal/v8/startup_snapshot'); | |
| 34 | 35 | ||
@@ -119,10 +120,18 @@ function requireForUserSnapshot(id) { | |||
| 119 | 120 | err.code = 'MODULE_NOT_FOUND'; | |
| 120 | 121 | throw err; | |
| 121 | 122 | } | |
| 122 | - if (!supportedInUserSnapshot(normalizedId)) { | ||
| 123 | + if (isBuildingSnapshot() && !supportedInUserSnapshot(normalizedId)) { | ||
| 123 | 124 | 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'); | ||
| 126 | 135 | warnedModules.add(normalizedId); | |
| 127 | 136 | } | |
| 128 | 137 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments