Skip to content

docs(workers): warn that background async needs await or waitUntil - #32626

Open
HaoChiBao wants to merge 2 commits into
cloudflare:productionfrom
HaoChiBao:docs/workers-waituntil-background-tasks
Open

docs(workers): warn that background async needs await or waitUntil#32626
HaoChiBao wants to merge 2 commits into
cloudflare:productionfrom
HaoChiBao:docs/workers-waituntil-background-tasks

Conversation

@HaoChiBao

Copy link
Copy Markdown

Summary

  • Add a short caution on ctx.waitUntil() explaining that async work which is neither awaited nor passed to waitUntil() may be canceled when the invocation ends.

Fixes #32086.

Why

Developers often start background tasks and return a response assuming the task continues. Without await or ctx.waitUntil(), the runtime can interrupt that work — dropping logs or leaving writes incomplete. The page already documents how to use waitUntil; it did not warn about the failure mode when it is omitted.

Test plan

  • Preview /workers/runtime-apis/context/#waituntil: caution renders above the common-uses list
  • Existing 30-second limit and example code unchanged

Fixes cloudflare#32086. Fire-and-forget promises are not kept alive after the
response returns unless registered with ctx.waitUntil().
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review

💡 1 suggestion found in commit 261f929.

👉 Fix in your agent 👈
Fix the following review findings in PR #32626 (https://github.com/cloudflare/cloudflare-docs/pull/32626).

Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
  or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.

The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.

---

## Style Guide Review

### Suggestions (1)

#### SG-d90e38b12068 · Serial comma
- **File:** `src/content/docs/workers/runtime-apis/context.mdx` line 212
- **Issue:** A list of three participial phrases (`dropping logs, leaving writes unfinished, or failing silently`) is joined by `or` without a comma before the final conjunction.
- **Fix:** Add a serial comma before `or`: `dropping logs, leaving writes unfinished, or failing silently``dropping logs, leaving writes unfinished, or failing silently`.

Code Review

This code review is in beta and may not always be helpful — use your judgment.

No code review issues found.

Conventions

No convention issues found.

Style Guide Review

Suggestions (1)
File Issue
workers/runtime-apis/context.mdx line 212 Serial comma — A list of three participial phrases (dropping logs, leaving writes unfinished, or failing silently) is joined by or without a comma before the final conjunction. Fix: Add a serial comma before or: dropping logs, leaving writes unfinished, or failing silentlydropping logs, leaving writes unfinished, or failing silently.
Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.
/disable-auto-review Stops automatic reviews from triggering on future pushes to this PR. Codeowners can still run /review or /full-review manually.
/rebase Rebases the PR branch against production. On conflict, attempts to resolve automatically using AI. Stops with an explanation if confidence is not high enough.

Drop advice already covered by the following paragraph; keep the failure mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

7 participants