Refactor HEAD method handling in compose.ts#1579
Conversation
WalkthroughThe HEAD request handling in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
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. Comment |
commit: |
Fixes #1569
The Bug
When a
HEADrequest is made to a route that uses async parameter destructuring (e.g.,get("/:id", async ({ params: { id } }) => { ... })), the server crashes with an error:❌ undefined is not an object (evaluating '_res.headers.set').The root cause was that the code handling
HEADrequests did not properly account for handlers returning aPromise. This led to an attempt to access the.headersproperty on aPromiseobject (which isundefined) instead of on the resolvedResponse.The Solution
The fix ensures the result of the route handler is properly resolved using
Promise.resolve()before proceeding. It also includes safeguards to ensure theheadersobject exists on the response before trying to modify it.Summary by CodeRabbit
Bug Fixes
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.