Skip to content

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Jan 23, 2026

When an empty response or JSON response is returned, H3 returns a response with with frozen headers to prevent sharing state across requests.

However currently it might but hard to investigate source of issue (when stack-traces are not helping)

This PR adds operation (set|append|delete) + arguments info to error to allow debugging better. (it costs ~20 bytes of bundle)

Summary by CodeRabbit

  • Refactor
    • Enhanced error messaging when attempting to modify frozen headers, providing clearer feedback to developers.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This PR refactors the header immutability mechanism in response handling by replacing a dedicated frozenHeaders function with a generic frozen(name) factory pattern, improving error messaging for modification attempts on frozen headers.

Changes

Cohort / File(s) Change Summary
Header Immutability Refactoring
src/response.ts
Replaces dedicated frozenHeaders function with generic frozen(name) factory. The FrozenHeaders class now uses these frozen wrappers for set, append, and delete operations with enhanced error reporting. No changes to header read/creation behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A frozen header's a stubborn friend,
Now wrapped in factory cheer!
Set, append, delete—they'll always defend,
With messages crystal clear! 🔒✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main refactoring: improving error messages for frozen headers to enable better debugging by adding operation and argument details.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/h3js/h3@1287

commit: 9c8e62d

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