Optionalcause: unknownOptional ReadonlycauseReadonlykindDiscriminated tag for exhaustive matching.
OptionalstackStaticstackThe Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
StaticcaptureCreates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
OptionalconstructorOpt: FunctionStaticprepare
Raised when the shared wasm instance has been POISONED by a Rust trap (a
panicon wasm32, which — with no unwinding — aborts mid-mutation as anunreachableand surfaces in JS as aWebAssembly.RuntimeError).Remarks
SPEC §5.2 / §3 Theorem 3 pin commit atomicity: a rejected commit is a perfect no-op, and the JS mirror can be rolled back byte-identically because the engine rolled ITSELF back. That claim holds only for a clean engine REJECTION (a typed verdict returned across the FFI). It does NOT hold for a trap: wasm32 has no stack unwinding, so a panic that aborts inside
apply_commandsleaves the engine'sStateUNDEFINED — the derived arm may havemem::take'd it out of the per-engine registry slot, strandingState::default(). Rolling the JS mirror back on that path would falsely assert §5.2 atomicity and actively diverge the mirror from the poisoned engine, while the possibly-corrupt shared instance kept serving every engine multiplexed on it (causl-client#127).On a trap the backend instead marks the SHARED instance dead and fails loud: this error is thrown by the engine that trapped (carrying the underlying
WebAssembly.RuntimeErrorascause) and by EVERY subsequent operation on ANY engine multiplexed on that instance — so a poisoned instance can never silently serve divergent state. Recovery requires a fresh instance (rebuild the graph); the poisoned one is never reused.Param: cause
The underlying trap (
WebAssembly.RuntimeError) when this is the engine that trapped;undefinedon a subsequent fail-loud throw.