Skip to content

bug: useRealtimeRun onComplete fires prematurely in self-hosted environment (Traefik + Docker Compose) #2856

@bbreunig

Description

@bbreunig

Provide environment information

Environment Information

System:

OS: macOS 15.7
CPU: (36) x64 Intel(R) Xeon(R) W-2191B CPU @ 2.30GHz
Memory: 71.57 GB / 128.00 GB
Shell: 5.9 - /bin/zsh

Binaries:

Node: 23.6.1 - /Users/<home>/.nvm/versions/node/v23.6.1/bin/node
npm: 10.9.2 - /Users/<home>/.nvm/versions/node/v23.6.1/bin/npm
pnpm: 10.19.0 - /Users/<home>/Library/pnpm/pnpm

Reproduction Environment

  • Hosting: Self-hosted using the standard Trigger.dev docker-compose.yml.
  • Reverse Proxy: Traefik.
  • Hook Config: Using baseURL pointing to the Traefik entrypoint for the Trigger API.
  • SDK Versions: @trigger.dev/sdk@4.3.2, @trigger.dev/react-hooks@4.3.2.
  • Framework: Next.js 16.10.0 / React 19.2.0

Infrastructure Details

The instance is running behind Traefik using the default Docker Compose setup. While the onComplete callback fires early, the run state returned by the hook does continue to update correctly in the UI as the task progresses, eventually reaching COMPLETED. This suggests the realtime connection itself is working, but the logic governing the callback trigger is misfiring in this network environment.

Describe the bug

When using the useRealtimeRun hook with a self-hosted Trigger.dev instance, the onComplete callback fires immediately upon the first successful data fetch, even if the run is still in an active state (e.g., EXECUTING).

Reproduction repo

None

To reproduce

Reproduction Steps

  1. Trigger a task that includes a significant delay (e.g., 5-10 seconds).
  2. Use useRealtimeRun in a client component with a baseURL and an onComplete callback.
const { run } = useRealtimeRun(runId, {
     accessToken: publicToken,
     baseURL: "https://your-self-hosted-trigger.com",
     onComplete: (run) => {
       console.log("onComplete called with status:", run.status);
     }
   });
  1. Observe that onComplete is called almost immediately after the component mounts.
  2. Logging the run object inside onComplete shows status: "EXECUTING".### Expected Behavior
    onComplete should only be called once the run reaches a terminal state (COMPLETED, FAILED, CANCELED, CRASHED).

Actual Behavior

onComplete is called immediately with the non-terminal state.

Additional information

I also checked traefik logs but there were no issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions