Skip to content

fix(cli): Require return await for returned promises - #1556

Merged
BYK merged 3 commits into
mainfrom
byk/lint-return-await
Oct 21, 2026
Merged

BYK merged 3 commits into
mainfrom
byk/lint-return-await

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #1552.

When an async function returns a promise without awaiting it, the caller's frame drops out of async stack traces. This PR turns on type-aware Oxlint through oxlint-tsgolint, using options.typeAware in .oxlintrc.json. That covers pnpm run lint, CI, lint-staged and the editor. It also enables typescript/return-await with the always option for packages/cli/src/**. All 89 existing hits are fixed. None needed a suppression.

Things to look at:

  • sentry-client.ts executeAttempt: inside a try, return await is not just cosmetic: rejections then hit the local catch. Here that would have routed handleResponse errors (such as MalformedAuthTokenError) through handleFetchError, and sentry-client.auth.test.ts caught it. So handleResponse now runs after the try, which keeps the old behavior. The only other hit inside a try is in local/daemon.ts, in the catch. There, an ENOENT from the retried tryClaim() now gets one more claim attempt instead of propagating directly, which is harmless.
  • Other type-aware rules are off for now: turning on type-aware mode also activates the correctness-category rules that need types. Nine of them already have a backlog: await-thenable (275 hits), no-base-to-string, no-floating-promises, unbound-method, restrict-template-expressions, and a few smaller ones. They're set to off at the root, so lint behaves exactly as before apart from the new rule. We can turn them back on one at a time later.
  • Needed for tsgo: baseUrl is removed from apps/local/tsconfig.app.json and packages/mcp-cloudflare/tsconfig.client.json. tsgo rejects it, and paths already resolve relative to the config file. The SvelteKit init-eval template is ignored because its tsconfig extends a generated .svelte-kit/tsconfig.json. apps/local also gets two void navigate(...) calls, because its nested config started showing no-floating-promises warnings.
  • Lint time: Oxlint on the whole repo goes from about 1s to about 3s.

Gap: return-await only checks async functions. A non-async wrapper like the original fetchAccountOrgs (function f(): Promise<T> { return withStoredAccount(...) }) still passes. To catch that we'd need typescript/promise-function-async, which has about 265 hits in the CLI and makes sync throws reject. That seemed better as a separate change.

via byk.

--

View Junior Session in Sentry

Enable type-aware Oxlint (oxlint-tsgolint) and turn on
typescript/return-await ("always") for packages/cli/src so returning an
un-awaited promise from an async function fails lint. Returning without
await drops the caller's frame from async stack traces.

Fix the 89 existing hits. In sentry-client executeAttempt, move
handleResponse out of the try block so awaiting it does not route
response-handling errors through handleFetchError.

Type-aware correctness rules with an existing backlog are turned off at
the root for now. Drop baseUrl from two tsconfigs (unsupported by tsgo;
paths already resolve relative to the config) and ignore the SvelteKit
init-eval template, whose tsconfig extends a generated file.

Fixes #1552

Co-authored-by: byk <burak.kaya@sentry.io>
Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Oct 21, 2026 2:20pm UTC

Request Review

Comment thread apps/local/src/routes/local-workspace-route.tsx
Comment thread packages/cli/src/commands/dashboard/restore.ts Outdated
Comment thread packages/cli/src/lib/polling.ts
Comment thread scripts/oxc-config.test.mjs Outdated
Comment thread .oxlintrc.json
Comment thread .oxlintrc.json Outdated
Move typescript/return-await ("always") from the CLI override to the
root config (and apps/local's own config) and fix the ~100 remaining
hits across MCP packages, apps/local and scripts.

In mcp-cloudflare's /oauth/register guard, build the rejection response
outside the try so a finalizeResponse failure is not swallowed by the
malformed-body catch.

Replace the dashboard `.catch(async (error) => enrichDashboardError(...))`
call sites with a withDashboardErrors(ctx, fn) helper, drop the config
assertion test, and document the void/await choices inline.

Refs #1552, #1573

Co-authored-by: byk <burak.kaya@sentry.io>
Co-Authored-By: Claude <noreply@anthropic.com>
Add a repo-wide ast-grep rule, no-async-catch-callback, so the
`.catch(async (error) => ...)` pattern replaced by withDashboardErrors
can't come back, and note it in the coding guidelines.

Co-authored-by: byk <burak.kaya@sentry.io>
Co-Authored-By: Claude <noreply@anthropic.com>
@BYK
BYK enabled auto-merge (squash) October 21, 2026 14:22
@BYK
BYK merged commit b29ae76 into main Oct 21, 2026
41 of 42 checks passed
@BYK
BYK deleted the byk/lint-return-await branch October 21, 2026 14:34
sentry-junior Bot added a commit that referenced this pull request Oct 21, 2026
Turn the nine type-aware rules back on and fix the violations they
report: drop awaits on non-thenables, mark intentional fire-and-forget
promises with void, await forgotten assertions, give sorts explicit
comparators, stop stringifying unknown values to "[object Object]", and
remove redundant type constituents.

no-floating-promises allows node:test's test/describe helpers,
restrict-template-expressions allows never, and unbound-method stays off
in tests, where mock and identity assertions trip it.

Fixes #1573

Co-Authored-By: BYK <burak.kaya@sentry.io>

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 331f427b Deployed Oct 21, 2026 by vercel[bot]
Actions — 331f427b Deployed Oct 21, 2026 by sentry-junior[bot] via eval #1346
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint: require return await for returned promises (type-aware oxlint)

1 participant