#Status `REATTEMPTING` does not exist anymore. Replaced by what?

1 messages · Page 1 of 1 (latest)

vague wigeon
#

I'm using the v4 beta.

I had this logic in place to count attempts

  useEffect(() => {
    if (!run) return;
    console.log('🚀 ~ run:', run);
    if (run.status === 'QUEUED') {
      setIsLoading(true);
    }
    if (run.status === 'REATTEMPTING') {
      setAttempt((prev) => prev + 1);
    }
    if (run.status === 'FAILED' || run.status === 'COMPLETED') {
      setIsLoading(false);
    }
    if (run.status === 'COMPLETED' && run.output) {
      callback({
        url: new URL(run.output),
        isRandom: false,
        router,
      });
      setIsLoading(false);
      setOpen(false);
    }
  }, [run?.status]);

Now, after upgrading to 4.0.0-v4-beta.25, I get a typescript error: error TS2367: This comparison appears to be unintentional because the types '"PENDING_VERSION" | "QUEUED" | "DEQUEUED" | "EXECUTING" | "WAITING" | "COMPLETED" | "CANCELED" | "FAILED" | "CRASHED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED" | "TIMED_OUT"' and '"REATTEMPTING"' have no overlap.

What do you recommend I do?

rigid breachBOT
#

Hi @vague wigeon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

In v4 of Trigger.dev, the status REATTEMPTING has been removed from the run status enum. The new set of statuses in v4 includes: PENDING_VERSION, QUEUED, DEQUEUED, EXECUTING, WAITING, COMPLETED, CANCELED, FAILED, CRASHED, SYSTEM_FAILURE, DELAYED, EXPIRED, and TIMED_OUT. REATTEMPTING is not present in this list, which is why you are seeing a TypeScript error when checking for it in your code.

What should you do?

  • To track attempts, you should now rely on the attempt number (e.g., ctx.attempt.number) or other available run properties, rather than the REATTEMPTING status.
  • If you want to increment your attempt counter, you may need to look for changes in the attempt number or handle retries differently, since there is no direct replacement status for REATTEMPTING in v4.
  • Remove or refactor any logic that checks for run.status === "REATTEMPTING", as this status no longer exists in v4.

The knowledge sources do not specify a direct replacement for REATTEMPTING, but they confirm its removal and provide the new list of statuses you should use instead. You can see the new statuses in the Realtime overview documentation and in the runs documentation.

Example update:

useEffect(() => {
  if (!run) return;
  if (run.status === 'QUEUED') {
    setIsLoading(true);
  }
  // Remove REATTEMPTING logic, consider using attempt number if available
  if (run.status === 'FAILED' || run.status === 'COMPLETED') {
    setIsLoading(false);
  }
  if (run.status === 'COMPLETED' && run.output) {
    callback({
      url: new URL(run.output),
      isRandom: false,
      router,
    });
    setIsLoading(false);
    setOpen(false);
  }
}, [run?.status]);
#

If you need to count attempts, you may want to track changes in the attempt number instead of relying on a status value.

For more details on the new statuses and run lifecycle, see the runs documentation and Realtime overview.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@vague wigeon Kapa.ai is still learning and improving, please let me know how I did by reacting below.