Skip to content

Worker should pass abortSignal to handlers #115

@jumski

Description

@jumski

The second argument to handlers (both queue and flow based) should accept a "context" object.
This is intended for few custom utilities and be extendable in future for user-defined api clients and stuff.

But the first implementation should just pass abortSignal so users can pass it to fetch and other abortable calls to gracefully abort when worker is shutting down.

This signal should be composed of the main shutdown signal AND message-specific timeout signal using AbortSignal.any() so we can also timeout handlers properly.

Proposed api:

queue worker:

EdgeWorker.start(async (payload, { abortSignal }) => {
  // do stuff and optionally abort
});

flow worker:

.step(
  { slug: "website", timeout: 30 }, 
  async (input, { abortSignal }) => {
    // do stuff and optionally abort
})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions