@nevware21/ts-async - v0.6.1
    Preparing search index...

    Function setMaxSyncPromiseChainDepth

    • Sets the maximum number of consecutive promise reaction continuations (chained then/catch/finally handlers 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 eventual RangeError: Maximum call stack size exceeded) which could otherwise occur when synchronously resolving very deep or recursively chained promises, or a "hostile" thenable whose then() 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.

      Parameters

      • 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.

      Returns void

      0.7.0

      // Reduce the depth for more constrained environments
      setMaxSyncPromiseChainDepth(50);

      // Disable the guard (not recommended)
      setMaxSyncPromiseChainDepth(0);

      // Restore the default
      setMaxSyncPromiseChainDepth(200);