You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot make a node-fetch request, TypeError: Cannot read property 'Symbol(requestOptions)' of undefined #36364
Platform: MINGW64_NT-10.0-17763 DESKTOP-GJB54B0 3.0.7-338.x86_64 2019-04-30 21:52 UTC x86_64 Msys
Subsystem:
What steps will reproduce the bug?
Any call to foreign api, using a trusted library like "node-fetch", creates error and crash servers, on versions higher than 12.18
Here is the error:
_http_agent.js:444
options = req[kRequestOptions];
^
TypeError: Cannot read property 'Symbol(requestOptions)' of undefined
at Agent.removeSocket (_http_agent.js:444:20)
at TLSSocket.onClose (_http_agent.js:371:11)
at TLSSocket.emit (events.js:327:22)
at net.js:673:12
at TCP.done (_tls_wrap.js:563:7)
How often does it reproduce? Is there a required condition?
All the time, not in version 12.18 or lower
What is the expected behavior?
a normal fetch, returning the result from any api, mostly a json
I tracked down the issue and found out that one of the libs in the project, was defining methods on Object and Array Prototype.
When I removed it, it all started to work,
I wonder, what has changed after node v.12.18, that does not allow defining methods on Object/Array prototype??
I tracked down the issue and found out that one of the libs in the project, was defining methods on Object and Array Prototype.
When I removed it, it all started to work,
I wonder, what has changed after node v.12.18, that does not allow defining methods on Object/Array prototype??
This may be due to expanded use of what we call primordials on the project. The idea is that if a user changes the Object prototype, it should affect their code but not Node.js internal code. This is a security precaution but it may cause difficulty for people who "monkey-patch" Node.js internals like AMP vendors. I'd be curious to know what library is exhibiting this problem so we can track down whether this is expected breakage or a bug in Node.js that we need to fix.
I tracked down the issue and found out that one of the libs in the project, was defining methods on Object and Array Prototype.
When I removed it, it all started to work,
I wonder, what has changed after node v.12.18, that does not allow defining methods on Object/Array prototype??
This may be due to expanded use of what we call primordials on the project. The idea is that if a user changes the Object prototype, it should affect their code but not Node.js internal code. This is a security precaution but it may cause difficulty for people who "monkey-patch" Node.js internals like AMP vendors. I'd be curious to know what library is exhibiting this problem so we can track down whether this is expected breakage or a bug in Node.js that we need to fix.
Though it looks like @targos has already self-assigned this so they probably have a good idea what the bug is and what the fix is.
To explain the bug: there was a semver-minor change that introduced a for ... in loop on the requests property of http Agent.
If enumerable properties were added to Object.prototype, they would be iterated by this loop, triggering this bug because they probably wouldn't have an object at index 0.
Activity
RaisinTen commentedon Dec 3, 2020
I'm having some difficulty reproducing this:
As you can see, it exits with a zero error code.
seven-deuce commentedon Dec 4, 2020
I tracked down the issue and found out that one of the libs in the project, was defining methods on Object and Array Prototype.
When I removed it, it all started to work,
I wonder, what has changed after node v.12.18, that does not allow defining methods on Object/Array prototype??
http: use objects with null prototype in Agent
Trott commentedon Dec 9, 2020
This may be due to expanded use of what we call
primordialson the project. The idea is that if a user changes theObjectprototype, it should affect their code but not Node.js internal code. This is a security precaution but it may cause difficulty for people who "monkey-patch" Node.js internals like AMP vendors. I'd be curious to know what library is exhibiting this problem so we can track down whether this is expected breakage or a bug in Node.js that we need to fix.Trott commentedon Dec 9, 2020
Though it looks like @targos has already self-assigned this so they probably have a good idea what the bug is and what the fix is.
targos commentedon Dec 9, 2020
#36409 and #36410 are the pull requests that fix this issue. I referenced the issue in the PRs but forgot to do the opposite here, sorry!
targos commentedon Dec 9, 2020
To explain the bug: there was a semver-minor change that introduced a
for ... inloop on therequestsproperty of httpAgent.If enumerable properties were added to
Object.prototype, they would be iterated by this loop, triggering this bug because they probably wouldn't have an object at index0.http: do not loop over prototype in Agent
http: do not loop over prototype in Agent
http: do not loop over prototype in Agent
http: do not loop over prototype in Agent
http: use objects with null prototype in Agent