Skip to content

fix(server): catch synchronous exceptions in middleware passes#109

Merged
pi0 merged 1 commit intomainfrom
fix/forward-parsing-errors
Mar 25, 2026
Merged

fix(server): catch synchronous exceptions in middleware passes#109
pi0 merged 1 commit intomainfrom
fix/forward-parsing-errors

Conversation

@pi0
Copy link
Copy Markdown
Member

@pi0 pi0 commented Mar 25, 2026

Summary

  • Wraps middleware pass execution in _createProxyFn with try/catch to handle synchronous exceptions (e.g., ERR_INVALID_HTTP_TOKEN from invalid headers)
  • When an error listener exists, the error is emitted via the error event; otherwise the promise rejects
  • Adds regression tests for both error-listener and promise-rejection paths

Ref: http-party/node-http-proxy#1680

Test plan

  • New test: synchronous pass error is forwarded to error event when listener exists
  • New test: synchronous pass error rejects the promise when no error listener
  • Full test suite passes (228 tests, 0 failures)

Forward synchronous errors thrown by middleware passes (e.g. ERR_INVALID_HTTP_TOKEN)
to the error event instead of crashing the process.

Ref: http-party/node-http-proxy#1680
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

Warning

Rate limit exceeded

@pi0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 55 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ac1f4585-4edd-4a6b-9e9c-eeae429e4641

📥 Commits

Reviewing files that changed from the base of the PR and between 11f3657 and 68e7c1d.

📒 Files selected for processing (2)
  • src/server.ts
  • test/index.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/forward-parsing-errors

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.26%. Comparing base (8ab2a3b) to head (68e7c1d).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
+ Coverage   96.14%   96.26%   +0.11%     
==========================================
  Files           8        8              
  Lines         623      643      +20     
  Branches      233      241       +8     
==========================================
+ Hits          599      619      +20     
  Misses         24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pi0 pi0 merged commit b7075ab into main Mar 25, 2026
7 checks passed
@pi0 pi0 deleted the fix/forward-parsing-errors branch March 25, 2026 20:28
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