node/lib/internal/main
Joyee Cheung 1f6b681bf2 src: fix timing of snapshot serialize callback
Previously the addAfterUserSerailizeCallback() wasn't
ready to be used for building the built-in snapshot.
This patch initializes the callbacks at the time
lib/internal/v8/start_snapshot.js is loaded, so that
these callbacks get run correctly when building the
built-in snapshot.

Currently when building the built-in snapshot,
addAfterUserSerializeCallback() is only used by createUnsafeBuffer(),
other usages can only come from user-land snapshots,
which is covered by tests, but what gets run by the
built-in snapshot building process is less visible, and the
path used by createUnsafeBuffer() isn't reliably visible in user
land either. This adds an internal usage counter in debug builds
to verify this path when building the built-in snapshot.

PR-URL: https://github.com/nodejs/node/pull/60434
Fixes: https://github.com/nodejs/node/issues/60423
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2025-10-28 00:15:55 +00:00
..
check_syntax.js module: remove --experimental-default-type 2024-12-02 22:43:55 +00:00
embedding.js src,lib: obtain sourceURL in magic comments from V8 2025-05-30 09:47:20 +00:00
eval_stdin.js lib: add typescript support to STDIN eval 2024-12-29 22:42:51 +00:00
eval_string.js module: support eval with ts syntax detection 2024-12-24 16:48:02 +00:00
inspect.js lib: enforce use of trailing commas 2023-03-06 10:44:14 +01:00
mksnapshot.js src: fix timing of snapshot serialize callback 2025-10-28 00:15:55 +00:00
print_help.js bootstrap: print --help message using console.log 2024-05-12 21:43:13 +02:00
prof_process.js lib: enforce use of trailing commas 2023-03-06 10:44:14 +01:00
repl.js repl: extract and standardize history from both repl and interface 2025-05-28 07:38:39 +00:00
run_main_module.js module: remove --experimental-default-type 2024-12-02 22:43:55 +00:00
test_runner.js test_runner: unify --require and --import behavior when isolation none 2025-05-06 06:28:29 +00:00
watch_mode.js src: add watch config namespace 2025-10-20 13:53:29 +02:00
worker_thread.js module: refactor and clarify async loader hook customizations 2025-10-23 13:42:23 +00:00