-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add comprehensive test suite for error handling (PR #9275) #9277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Move error tracking logic to separate module to break circular dependency between index.ts and exit.ts. This was causing esbuild to generate invalid code with misplaced await keywords. - Create new errorTracking.ts module - Move hasUnhandledError flag and related functions to errorTracking.ts - Update imports in index.ts and exit.ts to use new module Co-authored-by: nate <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 5 files
|
This PR adds comprehensive tests for the error handling improvements in PR #9275. Since this PR only adds test files and doesn't change any user-facing behavior or features, no documentation updates are required. The error handling improvements (exiting with non-zero codes on unhandled errors) are internal implementation details that work automatically without requiring user awareness or configuration changes. |
Move hasUnhandledError flag and functions to errorTracking.ts to avoid circular dependency issues when bundling. This fixes the syntax error that was occurring when the bundler tried to handle imports from the entry point (index.ts). Fixes: SyntaxError: Unexpected reserved word in bundled code Co-authored-by: peter-parker <[email protected]> Generated with Continue (https://continue.dev) Co-Authored-By: Continue <[email protected]>
- Add 23 tests for gracefulExit and updateAgentMetadata functions - Add 10 unit tests for error tracking and exit code transformation - Test exit code coercion (0 -> 1 when errors occur) - Test preservation of non-zero exit codes - Test telemetry/sentry flushing with error handling - Test metadata collection and API reporting - Add comprehensive test documentation Co-authored-by: peter-parker <[email protected]> Generated with Continue (https://continue.dev) Co-Authored-By: Continue <[email protected]>
Update test imports to use the new errorTracking.ts module instead of index.ts to match the refactoring that fixed the bundling issue. Co-authored-by: peter-parker <[email protected]> Generated with Continue (https://continue.dev) Co-Authored-By: Continue <[email protected]>
146079c to
5670589
Compare
0788183 to
635aa42
Compare
Summary
This PR adds comprehensive tests for the error handling improvements made in PR #9275.
Changes
Test Coverage
Exit Code Transformation
✅ Exit with code 0 when no errors
✅ Exit with code 1 when unhandled error occurred and code 0 requested
✅ Preserve non-zero exit codes even if unhandled error occurred
✅ Preserve SIGINT exit code (130) even if unhandled error occurred
Telemetry and Sentry Flushing
✅ Flush telemetry and sentry before exiting
✅ Handle telemetry shutdown errors gracefully
✅ Handle sentry flush errors gracefully
✅ Handle both telemetry and sentry errors gracefully
Metadata Collection and Posting
✅ Update metadata with diff stats, summary, and usage
✅ Handle git diff errors gracefully
✅ Handle summary extraction errors gracefully
✅ Handle usage calculation errors gracefully
✅ Handle API posting errors gracefully
Error Tracking Behavior
✅ Track unhandled rejection flag
✅ Track uncaught exception flag
✅ Persist error flag after being set
✅ Only report to API when agent ID is set
Running the Tests
Documentation
See
src/test-documentation.mdfor detailed documentation of all test scenarios and implementation details.This agent session was co-authored by peter-parker and Continue.
Summary by cubic
Adds a comprehensive test suite for CLI error handling to verify exit code coercion (0→1 on unhandled errors), graceful telemetry/Sentry shutdown, and safe agent metadata reporting. Improves confidence in the behavior introduced by PR #9275 and documents the scenarios covered.
New Features
Dependencies
Written for commit 5670589. Summary will update automatically on new commits.