trigger.dev icon indicating copy to clipboard operation
trigger.dev copied to clipboard

bug: `useRealtimeRun` hook `onComplete` triggers on `QUEUED` state

Open cachho opened this issue 7 months ago • 2 comments

Provide environment information

System: OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa) CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor Memory: 2.98 GB / 15.59 GB Container: Yes Shell: 3.7.1 - /usr/bin/fish Binaries: Node: 18.20.8 - ~/.local/share/nvm/v18.20.8/bin/node npm: 10.8.2 - ~/.local/share/nvm/v18.20.8/bin/npm pnpm: 8.6.3 - ~/.local/share/pnpm/pnpm

Describe the bug

Image

Reproduction repo

n/a

To reproduce

  const { run, error } = useRealtimeRun<typeof decryptLink>(runId, {
    accessToken: publicAccessToken,
    // eslint-disable-next-line @typescript-eslint/no-shadow
    onComplete: (run) => {
      console.log('🚀 ~ run (onComplete):', run);
      setIsLoading(false);
      if (run.output) {
        callback({
          url: new URL(run.output),
          isRandom: false,
          router,
        });
      }
    },
  });

Additional information

beta 4.11

the easiest fix is to check for the status in the onComplete callback

cachho avatar Apr 30 '25 22:04 cachho

Actually, it only runs on QUEUED and not as intended on failed or completed.

Image

cachho avatar Apr 30 '25 22:04 cachho

facing the same issue

mateusztylec avatar Aug 19 '25 13:08 mateusztylec