fix: handle unhandled promise rejections in retry behavior by JustinBeckwith · Pull Request #757 · JustinBeckwith/linkinator · GitHub
Skip to content

fix: handle unhandled promise rejections in retry behavior - #757

Merged
JustinBeckwith merged 1 commit into
mainfrom
fix-retry-crash-754
Dec 4, 2025
Merged

JustinBeckwith merged 1 commit into
mainfrom
fix-retry-crash-754

Conversation

@JustinBeckwith

Copy link
Copy Markdown
Owner

Summary

Fixes #754

  • Wrap top-level await main() in try-catch to handle errors gracefully
  • Add .catch() to queue item execution to prevent unhandled promise rejections
  • Add test case to prevent regression

Root Cause

Two issues were causing the "unsettled top-level await" crash when retry behavior failed:

  1. cli.ts: The top-level await main() had no error handling. When errors occurred during retries, they propagated as unhandled rejections.

  2. queue.ts: The queue used .finally() but no .catch(). When queued promises (like retry crawls) rejected, the errors were unhandled.

Test plan

  • All 223 existing tests pass
  • Added new test should handle all retries failing without crashing (issue #754) that simulates the crash scenario

🤖 Generated with Claude Code

Fix crash with "unsettled top-level await" warning when retry behavior
causes link checks to fail. Two issues were causing the crash:

1. The top-level `await main()` in cli.ts had no error handling
2. The queue used `.finally()` but no `.catch()` for rejected promises

Changes:
- Wrap `await main()` in try-catch to handle errors gracefully
- Add `.catch()` to queue item execution to prevent unhandled rejections
- Add test case to prevent regression

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@JustinBeckwith
JustinBeckwith merged commit e16ce35 into main Dec 4, 2025
8 checks passed
@JustinBeckwith
JustinBeckwith deleted the fix-retry-crash-754 branch December 4, 2025 01:53
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.

Retry Behavior Causes Unsettled TLA Immediately After Failed Check

1 participant