fix: server crash on /theme.css request (ERR_STREAM_WRITE_AFTER_END)#39408
fix: server crash on /theme.css request (ERR_STREAM_WRITE_AFTER_END)#39408sahillllllllll-bit wants to merge 1 commit into
/theme.css request (ERR_STREAM_WRITE_AFTER_END)#39408Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (2)📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
🔇 Additional comments (1)
WalkthroughModified HTTP response Content-Length calculation in the theme CSS endpoint from using raw string length to using Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
Description
Fixes #39407
Requesting
/theme.cssmay crash the server with:This happens because the middleware ends the response using
res.end()but does not stop execution afterward. In some cases the request stream continues and attempts to write to the same response again, causing Node.js to throwERR_STREAM_WRITE_AFTER_END.This change ensures the middleware stops execution immediately after sending the response.
Additionally, the
Content-Lengthheader now usesBuffer.byteLengthinstead ofstring.lengthto correctly handle UTF-8 characters.Changes
res.end()Buffer.byteLength(style, 'utf8')for accurateContent-LengthSummary by CodeRabbit