Repository navigation
fix(node): scope FastResponse subclass instanceof and avoid nesting as global Response - #330
Conversation
…ng as global `Response`
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
commit: |
Resolves #329
When
FastResponseis installed asglobalThis.Response(Nitro on Node, nitrojs/nitro#4910):instanceof:static [Symbol.hasInstance]was inherited by subclasses, so withclass MyRes extends Response {}every native or fast response wasinstanceof MyRes. The widened check now only applies whenthis === NodeResponse; subclasses fall back to a prototype-chain check (same approach aspatchGlobalRequest()).NativeResponsewas captured fromglobalThis.Responseat module eval, so a re-evaluated srvx (Vite module runner reload, second srvx copy) wrapped the previousFastResponse, stacking layers per reload. AddedgetNativeResponse(), mirroringgetNativeRequest(): caches underSymbol.for("srvx.nativeResponse")and unwraps classes markedstatic _srvx = true.Tests in
test/node-global-response.test.tscover both (re-evaluation viavi.resetModules(), three generations).🤖 Generated with AI assistant
Summary by CodeRabbit
Response, including more reliable subclassinstanceofchecks and response text handling across repeated module loads.