Skip to content

[Bug]: Trusted function deadlines retain a timer for every completed request #138

Closed

Description

@jimhoyd

Runtime revision and environment

c984d72; Node 26.8.2, macOS arm64.

Minimal reproduction

Start TrustedFunctions with timeoutMs:60000 and an immediate function returning new Response('hello'). Use node:async_hooks to track Timeout resources during 100 sequential execute calls, then yield one setImmediate.

Relevant output

100 live Timeout resources remain after all 100 calls complete. src/trusted-functions.ts:80-85 creates an unref timer inside Promise.race but never clears it when invoke wins. unref does not cancel a timer. Each completed call later also constructs/rejects a timeout error unnecessarily.

Expected: retain the timer handle and clearTimeout in finally on success and failure. A regression should assert timers return to baseline after successful calls. This is bounded by the configured timeout, not a permanent leak; at sustained load pending timers scale with request rate times timeout. No production RSS estimate is claimed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions