Skip to content

improve handling of graceful abort when runs are about to be started #17

@halvko

Description

@halvko

If the run is gracefully aborted during a call to client.actor(...).start(...), the orchestrator crashes with

file:///usr/src/app/node_modules/apify-orchestrator/dist/clients/actor-client.js:103
            throw new Error(`Error starting Run: ${runName} (${this.id}).`);
                  ^

Error: Error starting Run: run-name (scraper/name).
    at ExtActorClient.enqueueAndWaitForStart (file:///usr/src/app/node_modules/apify-orchestrator/dist/clients/actor-client.js:103:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

after investigating I found no extra runs started or anything, and everything worked correctly after resurrection. I think how scary the error message looks is unfortunate, but I'm also uncertain if it can behave wrongly in cases where multiple start calls are done concurrently (e.g.

const [run1, run2] = Promise.all([
  actor.start('name1', ...),
  actor.start('name2', ...),
]);

or equivalent). If special care should be taken around actor.start (e.g. using Promise.allSettled or wrapping calls in try blocks) to ensure correct behavior I think it should at least be documented on the method 😌 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions