Usage in Deno
import { type StartupSnapshot } from "node:v8";
addSerializeCallback(callback: StartupSnapshotCallbackFn,data?: any,): void
Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit. This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
addDeserializeCallback(callback: StartupSnapshotCallbackFn,data?: any,): void
Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
The callback
and the data
(if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
to re-acquire resources that the application needs when the application is restarted from the snapshot.
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn,data?: any,): void
This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script. If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
isBuildingSnapshot(): boolean
Returns true if the Node.js instance is run to build a snapshot.