Electron serializes IPC payloads with the structured clone algorithm, which
does not carry JavaScript semantics across intact. Declared types describe
the value the main process returned; this type describes the value the
renderer actually receives:
An uncloneable member invalidates the whole payload. Functions, symbols,
promises, WeakMap, and WeakSet make structured clone throw
DataCloneError, and nothing arrives — so the result is
IpcUncloneable, not a partially-mapped object. This propagates out
of arrays, tuples, Map, Set, and nested objects.
Class instances are rejected when they carry methods, because a type
cannot distinguish an own function property (which throws) from a prototype
method (which is silently dropped). Return a plain data object instead.
A class with only data properties survives as a plain object, so
instanceof is false in the renderer.
Buffer arrives as Uint8Array. Electron converts it, so
readUInt32LE() and friends are absent on the other side.
Date, RegExp, Map, Set, Error, ArrayBuffer, and typed arrays
survive and keep their prototypes. Subclasses of them do not: a custom
Error arrives as a plain Error, without its added fields or methods.
Getters are flattened to the value they evaluated to at send time.
Applied automatically to the generated bridge's parameters and return types,
so a payload that cannot cross the boundary is a compile error at the call
site instead of undefined is not a function in the renderer.
Model what survives the IPC boundary.
Electron serializes IPC payloads with the structured clone algorithm, which does not carry JavaScript semantics across intact. Declared types describe the value the main process returned; this type describes the value the renderer actually receives:
WeakMap, andWeakSetmake structured clone throwDataCloneError, and nothing arrives — so the result is IpcUncloneable, not a partially-mapped object. This propagates out of arrays, tuples,Map,Set, and nested objects.instanceofis false in the renderer.Bufferarrives asUint8Array. Electron converts it, soreadUInt32LE()and friends are absent on the other side.Date,RegExp,Map,Set,Error,ArrayBuffer, and typed arrays survive and keep their prototypes. Subclasses of them do not: a customErrorarrives as a plainError, without its added fields or methods.Applied automatically to the generated bridge's parameters and return types, so a payload that cannot cross the boundary is a compile error at the call site instead of
undefined is not a functionin the renderer.