Skip to content

fix(server): handle relay usage callback errors#94

Merged
INONONO66 merged 1 commit into
mainfrom
fix/relay-stream-usage-errors
May 28, 2026
Merged

fix(server): handle relay usage callback errors#94
INONONO66 merged 1 commit into
mainfrom
fix/relay-stream-usage-errors

Conversation

@INONONO66
Copy link
Copy Markdown
Owner

@INONONO66 INONONO66 commented May 28, 2026

Summary

  • make RelayStream usage callbacks explicitly best-effort and non-blocking
  • catch synchronous throws, asynchronous rejections, and non-Error failure values before logging
  • add regression coverage for streaming and empty-body usage callback failures

Test plan

  • bun test tests/unit/sse-line-cap.test.ts
  • bun run typecheck
  • bun run build
  • bun test
  • bun run release-check

Fixes #51


Summary by cubic

Make RelayStream usage callbacks best-effort and non-blocking so they never delay or break streaming. All callback errors (sync, async, non-Error) are caught, normalized, and logged to avoid unhandled rejections.

  • Bug Fixes
    • onUsage now returns void | Promise<void> and is executed without blocking the stream.
    • Catch and log synchronous throws and asynchronous rejections.
    • Normalize non-Error failures to Error before logging.
    • Add regression tests for streaming and empty-body cases to ensure no unhandled rejections.

Written for commit 73f5ce0. Summary will update on new commits.

Review in cubic

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@INONONO66, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 22 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b128c3ca-7fe7-4d77-b5f2-b0a814145875

📥 Commits

Reviewing files that changed from the base of the PR and between 7102acc and 73f5ce0.

📒 Files selected for processing (2)
  • src/server/relay-stream.ts
  • tests/unit/sse-line-cap.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/relay-stream-usage-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.

@INONONO66 INONONO66 merged commit 1c6982b into main May 28, 2026
3 checks passed
@INONONO66 INONONO66 deleted the fix/relay-stream-usage-errors branch May 28, 2026 18:15
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.

streams: legacy RelayStream drops async onUsage callback errors

1 participant