-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix EnvHttpProxyAgent for the Node.js bundle #4064
base: main
Are you sure you want to change the base?
Conversation
The Dispatcher needs some methods from lib/api for EnvHttpProxyAgent, otherwise it's incomplete.
@@ -26,6 +26,9 @@ module.exports.createFastMessageEvent = createFastMessageEvent | |||
|
|||
module.exports.EventSource = require('./lib/web/eventsource/eventsource').EventSource | |||
|
|||
const api = require('./lib/api') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my local testing, it seems only Dispatcher.prototype.connect
from the api-connect
is missing when I used it for a local proxy. But my testing isn't very thorough, so I am not entirely sure if other methods may also be needed in other paths, in any case it seems a bit of a footgun to leave the Dispatcher partially complete in the Node.js bundle, so I included them all. I am not sure if it's against any principle to include the lib/api
parts in the Node.js bundle though. Happy to do a bit of refactoring to move it to somewhere less weird (IMO maybe a better place to put it is to at least assign/implement Dispatcher.prototype.connect
in lib/dispatcher/dispatcher
, so that the Dispatcher
can be used for proxy connection out of the box?)
Locally it increases the bundle size from 610KB+ to 650KB+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for context, this is done for the public entry point
Line 25 in ff18d8c
Object.assign(Dispatcher.prototype, api) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Can you add a test for it? |
This relates to...
Refs: nodejs/node#57165
Rationale
The Dispatcher needs some prototype methods from lib/api for EnvHttpProxyAgent, otherwise it's incomplete, and throws a
TypeError: this[kClient].connect is not a function
whenEnvHttpProxyAgent
is handling requests inside the Node.js bundle.Changes
Make the Dispatcher prototype complete in the Node.js bundle.
Features
Bug Fixes
Breaking Changes and Deprecations
Status