Skip to content

Workers docs could better explain why background async tasks need ctx.waitUntil() #32086

Description

@arianzagrosmachinery

Existing documentation URL(s)

https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/#context-waituntil

What changes are you suggesting?

It would be helpful if the Workers docs more clearly explained what can happen when async work is started but neither awaited nor passed to ctx.waitUntil().

This can be confusing for developers who assume a background task will continue running after a response is returned. In practice, those tasks may be interrupted, which can lead to lost logs, incomplete writes, or other silent failures.

suggested improvement:

Please add a short warning or example explaining that:

  • async work may not finish after the response is returned unless it is awaited or passed to ctx.waitUntil()
  • ctx.waitUntil() should be used for background tasks that must continue after returning a response

This would help prevent a common source of confusion in Workers.

Additional information

No response

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions