fix: use processModule as receiver when falling back in process polyfill (#541)#542
fix: use processModule as receiver when falling back in process polyfill (#541)#542guoyangzhen wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe process polyfill's proxy Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Applies upstream PR unjs/unenv#542 locally via pnpm patch. Resolves "Cannot read private member #n" error when deploying to vercel-edge / cloudflare workers. Patch can be removed once unenv releases the fix. Also enables vercel-edge preset and inline sourcemaps for the playground (sourcemaps to be removed after edge deploy verifies green).


🔗 Linked issue
Closes #541
📝 Description
The
processpolyfill uses a Proxy to layer unenv's polyfill over the original process object. When a property doesn't exist on the proxy target, it falls back toprocessModule(unenv's polyfill implementation):The problem:
receiveris the Proxy wrapping the original process, notprocessModule. WhenprocessModulehas getters that rely on private fields (like#stdoutin thestdimplementations),Reflect.getinvokes the getter withthis = receiver— which is the wrong object and lacks the private fields.This causes:
Fix
Pass
processModuleas the receiver instead ofreceiver:This ensures getters/methods on
processModuleare invoked withthis = processModule, which has the expected private fields.Credit
Solution identified by the issue reporter @unjs/unenv#541.
Summary by CodeRabbit