OptionalmaxDepth: number
The maximum number of consecutive synchronous continuations to allow before forcing an asynchronous (microtask) hop. Defaults to 200 when omitted / non-numeric. Passing zero or a negative value disables the guard so that continuations are always executed synchronously (the previous, unbounded, behavior) -- this is not recommended other than for compatibility purposes.
Sets the maximum number of consecutive promise reaction continuations (chained
then/catch/finallyhandlers becoming ready to run) that will be executed synchronously, within the same JavaScript call stack, before this library forces an async "hop" (microtask; or a 0ms timeout when Sinon fake timers are enabled) to unwind the stack before continuing. This is a safety-net against unbounded call-stack growth (and eventualRangeError: Maximum call stack size exceeded) which could otherwise occur when synchronously resolving very deep or recursively chained promises, or a "hostile" thenable whosethen()implementation resolves itself recursively and synchronously. The depth is only ever consumed while continuations are being run synchronously (eg. via createSyncPromise, or once an asynchronous processor's own timer / microtask / idle callback has already fired). When the limit is exceeded, the current continuation is deferred so the stack can unwind; this means very deep / recursive "sync" chains may yield asynchronously. The depth is automatically restored (effectively "reset") once execution returns to, or is resumed from, a genuine asynchronous boundary.