Bug

Dropped an await

漏了一个 await

After a refactor, an async call's promise is discarded, so writes happen out of order or errors vanish as unhandled rejections.

Applies to: Claude Code · Cursor · Codex · Copilot agent

Symptom

Intermittent "it saved but didn't show up" bugs, flaky tests, unhandled rejection warnings in logs.

Why it happens

Agents drop awaits when a function looks synchronous, especially right after making it async. agent-review lists it as AR022 (High severity).

Example

From the agent-review taxonomy (AR022).

ts
async function persist() {
  save(record); // returns Promise<void>; not awaited
}

Copy-paste fixes

Pick the files for the agents you use. Snippets are in English so they work in any repo.

Rules

Claude Code: add to CLAUDE.md

CLAUDE.md
## Async discipline
- When you make a function async (or call one), update every call site to `await` it or handle the
  promise explicitly. List the call sites you changed.
- Never leave a floating promise. If fire-and-forget is intended, write `void task().catch(report)` with a comment.
- Keep `@typescript-eslint/no-floating-promises` on; don't disable it to get green.
Rules

Codex, Copilot coding agent and others: add to AGENTS.md

AGENTS.md
## Async discipline
- When you make a function async (or call one), update every call site to `await` it or handle the
  promise explicitly. List the call sites you changed.
- Never leave a floating promise. If fire-and-forget is intended, write `void task().catch(report)` with a comment.
- Keep `@typescript-eslint/no-floating-promises` on; don't disable it to get green.
Cursor rule

Cursor: project rule

.cursor/rules/unawaited-promise.mdc
---
description: "AgentFails: Dropped an await"
globs: **/*.{ts,tsx,js,jsx}
alwaysApply: false
---

## Async discipline
- When you make a function async (or call one), update every call site to `await` it or handle the
  promise explicitly. List the call sites you changed.
- Never leave a floating promise. If fire-and-forget is intended, write `void task().catch(report)` with a comment.
- Keep `@typescript-eslint/no-floating-promises` on; don't disable it to get green.
CI / script

ESLint: make floating promises an error

eslint.config.mjs
// requires typed linting (typescript-eslint with parserOptions.projectService: true)
rules: {
  "@typescript-eslint/no-floating-promises": "error",
  "@typescript-eslint/no-misused-promises": "error",
}

Sources and credit

Related patterns

翻车 of the week

One real agent failure and its fix, every week. Free, short, no spam.