fix(require-fetch-try-catch): no-op false positive for await fetch inside directly-awaited async callback#47969
Merged
Conversation
6 tasks
…h inside directly-awaited async callback Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix false positive in require-fetch-try-catch rule
fix(require-fetch-try-catch): no-op false positive for await fetch inside directly-awaited async callback
Jul 25, 2026
pelikhan
marked this pull request as ready for review
July 25, 2026 09:53
Contributor
There was a problem hiding this comment.
Pull request overview
Refines the fetch safety rule to recognize awaited inline callbacks within try/catch.
Changes:
- Detects directly awaited callback wrappers and IIFEs.
- Adds valid cases for the new behavior.
- Preserves existing invalid nested-function cases.
Show a summary per file
| File | Description |
|---|---|
eslint-factory/src/rules/require-fetch-try-catch.ts |
Adds awaited-callback boundary handling. |
eslint-factory/src/rules/require-fetch-try-catch.test.ts |
Adds valid callback and IIFE tests. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Medium
Comment on lines
+84
to
+85
| ancestors[i - 1].type === AST_NODE_TYPES.CallExpression && | ||
| ancestors[i - 2].type === AST_NODE_TYPES.AwaitExpression |
Collaborator
|
@copilot run pr-finisherskill |
Collaborator
|
@copilot please run the Run: https://github.com/github/gh-aw/actions/runs/30155206984
|
Copilot stopped work on behalf of
pelikhan due to an error
July 25, 2026 11:02
Contributor
|
🎉 This pull request is included in a new release. Release: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isInsideTryBlockstopped at every function boundary unconditionally, soawait fetchinside an inline async callback was flagged even when the wrapping call was itselfawaited inside atryblock — meaning the rejection genuinely propagates to and is caught by the outer handler.Live false positive:
check_version_updates.cjs:92—await fetchinside awithRetry(async () => {...})callback that isawaited inside an outertry/catch.Changes
eslint-factory/src/rules/require-fetch-try-catch.tsFunctionExpression/ArrowFunctionExpressionboundary, check for the directly-awaited inline callback pattern before returningfalse:ancestors[i-1]is aCallExpression, andancestors[i-2]is anAwaitExpressionthat is itself inside atryblock with a handlerFunctionDeclarationstill always stops the walk (cannot be an inline argument)eslint-factory/src/rules/require-fetch-try-catch.test.tssetTimeout) remain invalidawait fetchinside an async callback that is itself awaited within an enclosing try [Content truncated due to length] #47931