Search code examples
apify

How to find the completion status of apify task run


How do you find the completion status (success, failure, or aborted) of an apify task run?

const crawler = new PhantomCrawler({
        input,
        requestQueue,
        dataset,
    });

    await crawler.run();

or if you have the

"actorId": ${JSON.stringify(process.env.APIFY_ACTOR_ID || null)},
"taskId": ${JSON.stringify(process.env.APIFY_ACTOR_TASK_ID || null)},
"runId": ${JSON.stringify(process.env.APIFY_ACTOR_RUN_ID || null)},

I see no reference in SDK or API

https://sdk.apify.com/docs/api/apify

https://docs.apify.com/api/v2#/reference/actors/actor-object/run-task


Solution

  • Each run (actor or task) has its status which you can get if you send the API call the GET run endpoint. When you call an actor or task, you get this run info back with its status.

    The code inside doesn't need to know its own status because if the code can ask for it, the task or actor is of course in the "RUNNING" state.