Repository: node
Issue: Support Node.js embedder objects and bindings in the snapshot
Labels: c++,snapshot

Here is a list of embedder object classes we have in core. In order to make userland snapshot possible (https://github.com/nodejs/node/issues/35711) we should support as many as possible of them.

Some of them can't simply be deserialized - for example, the `HandleWrap`s, because theoretically we can't resurrect a `uv_handle_t` from a snapshot, at best we can restore them by creating new ones, but that involves more work (which is system-specific) than "just deserialize the object". Some of them may be helper singletons that we can just throw away at serialization time and recreate upon deserialization, and some of them may not be supposed to be supported.

- [ ] `class HistogramBase : public BaseObject`: src/histogram.h
- [ ] `class ModuleWrap : public BaseObject`: src/module_wrap.h
- [ ] <del>`class Blob : public BaseObject`: src/node_blob.h</del>
- [x] `class BlobBindingData : public BaseObject`: src/node_blob.h
- [ ] `class MicrotaskQueueWrap : public BaseObject`: src/node_contextify.h
- [ ] `class ContextifyScript : public BaseObject`: src/node_contextify.h
- [ ] `class CompiledFnEntry final : public BaseObject`: src/node_contextify.h
- [ ] `class BindingData : public BaseObject`: src/node_http_parser.cc
- [ ] `class ConverterObject : public BaseObject`: src/node_i18n.h
- [ ] `class JSTransferable : public BaseObject`: src/node_messaging.h
- [x] `class FastHrtime : public BaseObject`: src/node_process_methods.cc (WIP at https://github.com/nodejs/node/pull/38905)
- [ ] `class SerializerContext : public BaseObject`: src/node_serdes.cc
- [ ] `class DeserializerContext : public BaseObject`: src/node_serdes.cc
- [x] `class SnapshotableObject : public BaseObject`: src/node_snapshotable.h
- [ ] `class NodeCategorySet : public BaseObject`: src/node_trace_events.cc
- [x] `class WeakReference : public BaseObject`: src/node_util.cc: https://github.com/nodejs/node/pull/44193
- [ ] `class WASI : public BaseObject`: src/node_wasi.h

The following are probably less likely to need support since they involve some kind of asynchronous state or references to opened system handles.

- [ ] `class Http2State : public BaseObject`: src/node_http2_state.h
- [ ] `class AsyncWrap : public BaseObject`: src/async_wrap.h
- [ ] `class PromiseWrap : public AsyncWrap`: src/async_wrap.cc
- [ ] `class ChannelWrap : public AsyncWrap`: src/cares_wrap.cc
- [ ] `class QueryWrap : public AsyncWrap`: src/cares_wrap.cc
- [ ] `class HandleWrap : public AsyncWrap`: src/handle_wrap.h
- [ ] `class HeapSnapshotStream : public AsyncWrap`: src/heap_utils.cc
- [ ] `class JSBindingsConnection : public AsyncWrap`: src/inspector_js_api.cc
- [ ] `class JSStream : public AsyncWrap`: src/js_stream.h
- [ ] `class FixedSizeBlobCopyJob : public AsyncWrap`: src/node_blob.h
- [ ] `class DirHandle : public AsyncWrap`: src/node_dir.h
- [ ] `class FileHandle final : public AsyncWrap`: src/node_file.h
- [ ] `class Http2Stream : public AsyncWrap`: src/node_http2.h
- [ ] `class Http2Session : public AsyncWrap`: src/node_http2.h
- [ ] `class Http2Ping : public AsyncWrap`: src/node_http2.h
- [ ] `class Http2Settings : public AsyncWrap`: src/node_http2.h
- [ ] `class Parser : public AsyncWrap`: src/node_http_parser.cc
- [ ] `class WorkerHeapSnapshotTaker : public AsyncWrap`: src/node_worker.cc
- [ ] `class Worker : public AsyncWrap`: src/node_worker.h
- [ ] `class CompressionStream : public AsyncWrap`: src/node_zlib.cc
- [ ] `class ReqWrap : public AsyncWrap`: src/req_wrap.h
- [ ] `class StreamPipe : public AsyncWrap`: src/stream_pipe.h
- [x] `class BindingData : public SnapshotableObject`: src/node_file.h
- [x] `class BindingData : public SnapshotableObject`: src/node_v8.h
- [ ] `class IntervalHistogram : public HandleWrap`: src/histogram.h
- [ ] `class MessagePort : public HandleWrap`: src/node_messaging.h
- [ ] `class StatWatcher : public HandleWrap`: src/node_stat_watcher.h
- [ ] `class TraceSigintWatchdog : public HandleWrap`: src/node_watchdog.h
- [ ] `class ProcessWrap : public HandleWrap`: src/process_wrap.cc
- [ ] `class SignalWrap : public HandleWrap`: src/signal_wrap.cc
- [ ] `class LibuvStreamWrap : public HandleWrap`: src/stream_wrap.h
- [ ] `class UDPWrap final : public HandleWrap`: src/udp_wrap.h
- [ ] `class Http2Stream::Provider::Stream : public Http2Stream`: src/node_http2.h
- [ ] `class ZlibStream : public CompressionStream`: src/node_zlib.cc
- [ ] `class BrotliCompressionStream : public CompressionStream`: src/node_zlib.cc
- [ ] `class GetAddrInfoReqWrap : public ReqWrap`: src/cares_wrap.cc
- [ ] `class GetNameInfoReqWrap : public ReqWrap`: src/cares_wrap.cc
- [ ] `class ConnectWrap : public ReqWrap`: src/connect_wrap.h
- [ ] `class FSReqBase : public ReqWrap`: src/node_file.h
- [ ] `class FileHandleReadWrap final : public ReqWrap`: src/node_file.h
- [ ] `class CloseReq final : public ReqWrap`: src/node_file.h
- [ ] `class SendWrap : public ReqWrap`: src/udp_wrap.cc
- [ ] `class ELDHistogram : public IntervalHistogram`: src/node_perf.h
- [ ] `class ConnectionWrap : public LibuvStreamWrap`: src/connection_wrap.h
- [ ] `class TTYWrap : public LibuvStreamWrap`: src/tty_wrap.h
- [ ] `class JSUDPWrap final : public UDPWrap`: src/js_udp_wrap.cc
- [ ] `class Http2StreamListener : public Stream`: src/node_http2.h
- [ ] `class ShutdownWrap : public Stream`: src/stream_base.h
- [ ] `class WriteWrap : public Stream`: src/stream_base.h
- [ ] `class ReportWritesToJSStreamListener : public Stream`: src/stream_base.h
- [ ] `class StreamBase : public Stream`: src/stream_base.h
- [ ] `class ReadableListener : public Stream`: src/stream_pipe.h
- [ ] `class WritableListener : public Stream`: src/stream_pipe.h
- [ ] `class FSReqCallback final : public FSReqBase`: src/node_file.h
- [ ] `class FSReqPromise final : public FSReqBase`: src/node_file.h
- [ ] `class PipeWrap : public ConnectionWrap`: src/pipe_wrap.h
- [ ] `class TCPWrap : public ConnectionWrap`: src/tcp_wrap.h
- [ ] `class SimpleShutdownWrap : public ShutdownWrap`: src/stream_base.h
- [ ] `class SimpleWriteWrap : public WriteWrap`: src/stream_base.h
- [ ] `class EmitToJSStreamListener : public ReportWritesToJSStreamListener`: src/stream_base.h
- [ ] `class CustomBufferJSListener : public ReportWritesToJSStreamListener`: src/stream_base.h

Another list for external references registration:

- [x] fs
- [ ] os
- [x] uv
- [x] v8
- [x] icu
- [x] url
- [x] blob
- [x] util
- [ ] wasi
- [x] zlib
- [ ] http2
- [x] types
- [x] buffer
- [x] <del>config</del> (all properties)
- [x] crypto (https://github.com/nodejs/node/pull/42203)
- [x] dtrace
- [x] errors
- [x] fs_dir
- [x] report
- [x] serdes
- [x] timers
- [x] worker
- [x] options
- [x] <del>symbols</del> (all properties)
- [x] profiler
- [x] tcp_wrap
- [ ] tls_wrap
- [x] tty_wrap
- [ ] udp_wrap
- [ ] watchdog
- [x] inspector
- [ ] js_stream
- [x] messaging
- [x] pipe_wrap
- [x] async_wrap
- [ ] block_list
- [ ] cares_wrap
- [x] contextify
- [x] heap_utils
- [x] mksnapshot
- [ ] spawn_sync
- [x] task_queue
- [x] credentials
- [ ] http_parser
- [ ] js_udp_wrap
- [ ] module_wrap
- [x] performance
- [x] signal_wrap
- [ ] stream_pipe
- [x] stream_wrap
- [ ] process_wrap
- [x] trace_events
- [x] fs_event_wrap
- [x] native_module
- [x] string_decoder
- [x] process_methods