Anchorage API reference
    Preparing search index...

    Class ThreadDurableObject<TEnv>Abstract

    Per-thread Durable Object base. Hosts subclass it, supply build() (their init() wiring) and route() (their thread routes), and bind the subclass under a wrangler namespace addressed idFromName(threadId).

    route() runs only AFTER the tenant assertion, so a track adding a route cannot forget it — the reason the dispatch is a template method rather than a fetch() each subclass writes.

    Type Parameters

    • TEnv = unknown
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    env: TEnv

    Absent in node tests; present under workerd.

    Accessors

    • get tenantId(): string

      The tenant this instance serves, decoded from its own thread id — the same salted-prefix decode used for runIds (one decode, tenantOfMemoryId to tenantOfRunId). Throws on a name carrying no valid tenant prefix: a hand-built or client-chosen threadId never reaches a tenant-scoped store.

      Returns string

    • get threadId(): string

      The thread this instance serves, recovered from its OWN idFromName identity — unforgeable at this boundary (id.name is populated only for idFromName-created ids). Throws rather than defaulting: a thread DO that cannot name itself cannot scope anything it stores.

      Returns string

    Methods

    • Serve a request whose tenant has already been asserted against this instance's identity. Abstract because the skeleton hosts no routes of its own: the durable-agent host drives the loop through scope.init.runtime, and the signals package mounts signal routes on the same asserted scope.

      Parameters

      Returns Promise<Response>