footprintjs - v11.2.0
    Preparing search index...

    Interface DetachDriver

    A driver is the WHEN/HOW of the detach. Maps (child, input, refId) to a DetachHandle whose lifecycle the driver owns.

    Drivers are themselves footprintjs primitives — internally they may be a single function or a multi-stage flowChart. Either way, the interface they expose to consumers is schedule(...).

    Drivers MUST:

    • Return synchronously (the agent loop never blocks on schedule)
    • Not throw — errors during scheduling route through the handle (handle.status = 'failed', handle.error = ...)
    • Honor the passive-recorder rule: the parent's detach* call never waits for the driver's deferred work to complete

    Drivers MAY:

    • Implement validate() for explicit caller-controlled preflight checks (e.g., assert navigator.sendBeacon exists). Scheduling must still contain failures when preflight was not requested.
    • Build their internal pipeline as a footprintjs flowChart for observability — driver implementation detail, not consumer-facing
    Built-in
    import { microtaskBatchDriver } from 'footprintjs/detach';
    const handle = driver.schedule(child, input, refId);
    Custom (BYOS)
    const lambdaExtensionDriver: DetachDriver = {
    name: 'lambda-extension',
    capabilities: { nodeSafe: true, survivesUnload: true },
    schedule(child, input, refId) {
    sharedBuffer.push({ refId, child, input });
    return createHandle(refId);
    },
    };
    interface DetachDriver {
        capabilities: DriverCapabilities;
        name: string;
        schedule(child: FlowChart, input: unknown, refId: string): DetachHandle;
        validate?(): void;
    }
    Index
    capabilities: DriverCapabilities

    What this driver supports. Used by consumers to pick the right driver for their environment.

    name: string

    Stable name for diagnostics + registry lookup. Conventionally algorithm-named (e.g. 'microtask-batch', 'send-beacon').

    • Hand the work to the driver's scheduling mechanism. MUST return synchronously with a fresh DetachHandle. The actual work may run later (next microtask / setImmediate / browser-beacon-flush / worker-thread / etc.) on the driver's chosen mechanism.

      Parameters

      • child: FlowChart
      • input: unknown
      • refId: string

      Returns DetachHandle

    • Optional preflight hook, invoked explicitly by the caller, never automatically by the detach entry points. It may throw if the configuration is invalid. schedule() must independently report scheduling failures through its handle, even without preflight.

      Example: sendBeaconDriver.validate() checks typeof navigator?.sendBeacon === 'function' and throws with a helpful message if absent (e.g., in Node).

      Returns void