Skip to content

Rethrow Panic from runners and narrow gen() result semantics#31

Merged
adelrodriguez merged 1 commit intomainfrom
03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics
Mar 7, 2026
Merged

Rethrow Panic from runners and narrow gen() result semantics#31
adelrodriguez merged 1 commit intomainfrom
03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics

Conversation

@adelrodriguez
Copy link
Copy Markdown
Owner

This pull request implements critical correctness fixes for error handling and panic semantics across the hardtry library.

Key Changes:

  • Panic rethrow behavior: run() and runSync() now rethrow user-thrown Panic instances instead of wrapping them, ensuring panic semantics remain consistent and preventing retry attempts on control errors
  • Simplified control error detection: Introduced ControlError base class for CancellationError and TimeoutError, replacing the checkIsControlError() utility function with direct instanceof checks
  • Generator failure semantics: gen() now throws unexpected failures unchanged while keeping GenResult narrow to only include explicit yielded/returned error values, avoiding the need to widen the public type with UnhandledException
  • Updated documentation: README now clarifies that run() and runSync() never return Panic as a result value

Test Coverage:

  • Added tests verifying Panic rethrow behavior in both sync and async execution paths
  • Updated generator tests to validate throw-through semantics for unexpected failures
  • Ensured retry logic correctly skips Panic instances

This maintains backward compatibility for normal error handling while fixing edge cases where control errors were incorrectly wrapped or returned as values.

Copy link
Copy Markdown
Owner Author

adelrodriguez commented Mar 7, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 7, 2026

Warning

Rate limit exceeded

@adelrodriguez has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 602de436-0c61-482f-933f-b13985c22882

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0cfde and c8ca403.

📒 Files selected for processing (11)
  • .plans/01-pr-18-review-triage-checklist.md
  • README.md
  • src/__tests__/index.test.ts
  • src/lib/__tests__/gen.test.ts
  • src/lib/__tests__/utils.test.ts
  • src/lib/errors.ts
  • src/lib/executors/__tests__/run.test.ts
  • src/lib/executors/base.ts
  • src/lib/executors/run-sync.ts
  • src/lib/executors/run.ts
  • src/lib/utils.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adelrodriguez adelrodriguez marked this pull request as ready for review March 7, 2026 17:37
Copy link
Copy Markdown
Owner Author

@codex review
@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 7, 2026

@adelrodriguez Sure, I'll review the changes in this PR!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@adelrodriguez adelrodriguez force-pushed the 03-07-change_drivegen_to_throw_errors_instead_of_returning_unhandledexception_ branch from 56c3a30 to 28f232d Compare March 7, 2026 18:04
@adelrodriguez adelrodriguez force-pushed the 03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics branch from 392c4f0 to 29c0fcf Compare March 7, 2026 18:04
@adelrodriguez adelrodriguez changed the base branch from 03-07-change_drivegen_to_throw_errors_instead_of_returning_unhandledexception_ to graphite-base/31 March 7, 2026 18:08
@adelrodriguez adelrodriguez force-pushed the 03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics branch from 29c0fcf to 37ef0c3 Compare March 7, 2026 18:08
@graphite-app graphite-app bot changed the base branch from graphite-base/31 to main March 7, 2026 18:08
@adelrodriguez adelrodriguez force-pushed the 03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics branch from 37ef0c3 to c8ca403 Compare March 7, 2026 18:08
Copy link
Copy Markdown
Owner Author

adelrodriguez commented Mar 7, 2026

Merge activity

  • Mar 7, 6:10 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 7, 6:10 PM UTC: @adelrodriguez merged this pull request with Graphite.

@adelrodriguez adelrodriguez merged commit c1ca3c6 into main Mar 7, 2026
6 checks passed
@adelrodriguez adelrodriguez deleted the 03-07-rethrow_panic_from_runners_and_narrow_gen_result_semantics branch March 7, 2026 18:10
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.

1 participant