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