-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
Uncaught TypeError: Cannot read property 'once' of undefined at EventEmitter.ee.once.req #427
Comments
I can recreate the issue, it's being caused by this line: Line 229 in 974473a
Nope, we just released v8.0.0, one of the new features was progress events (introduced in #322) which uses @sindresorhus We could easily stop errors in browsers by just testing |
@lukechilds thanks for following up. good to know I'm not crazy :) |
I think this should be fixed in the Browserify |
Good point, I'm not sure if browser APIs expose enough to implement I'll take a proper look tomorrow. |
Yeah, I've had a look and I don't think there's a reliable way to implement We could probably implement the functionality we need for progress with browser APIs and expose it through |
I have same issue in Node environnement. I try isolate code to demonstrate the bug. |
I'm having the same issue but only pops up when I'm using an agent in the options (node.js 8.9.1). The code that reproduced this issue: (error is thrown on the await statement).
|
@NotteJacob o_O Override |
@zckrs I need the agent for a proxied request. I'm currently using got version 7.1.0 which works without any issues |
I'm just surprised to fix my problem with this override. (node: v6.9.4 here) |
@zckrs oh, like that :-) So there might be something up with the agent handling of version 8.0.0 |
@zckrs @NotteJacob are you guys getting the exact same error as @austinfrey?
Because that's caused by the Browserify Bugs caused by using with |
@lukechilds I'm getting the exact same error when I use an http proxy agent in nodejs. I am not getting this error with got version 7.1.0, only with 8.0.0, haven't tried earlier version though.
This screenshot is my test script to reproduce the error with in the bottom left the error it throws |
@zckrs Spot on! Sorry, I totally overlooked that. @NotteJacob That still doesn't explain the agent issues you're experiencing though. Can you guys test this branch? It should resolve your problems. |
No problem. 😃 #429 resolve problem 🎉 |
@zckrs cany you just confirm, you have cache enabled right? |
No. Cache is disable :-/ |
Hmmn, ok, are you able to provide me with a reproducibe code example? |
#429 resolved my problem |
@lukechilds sorry I try to isolate code who reproduce bug but without success. |
Ok, this is going to be quite difficult to fix without being able to reproduce. Also, just to clarify, the issues you are experiencing (@NotteJacob and @zckrs) are completely seperate from the original post. It's the same property that doesn't exist but in a browser it's not expected to exist. In Node.js it should (unless coming from the cache). So #429 isn't a valid solution, it's just surpressing the errors. |
@zckrs @NotteJacob Are either of you interested in putting a fully working reproducible scenario together for me? Would love to get this fixed for you but I'm limited in what I can do without a repro. |
@lukechilds this zip file contains the index.js and package.json file which reproduces the error on my machine on Node version 8.9.1. |
@NotteJacob Thanks! |
I recently ran into the same issue reported by @zckrs and @NotteJacob while using a tool called renovate on a RHEL 7 system using Node 9.3.0. The error message I receive is: /app/node_modules/got/index.js:230
req.connection.once('connect', () => {
^
TypeError: Cannot read property 'once' of null
at EventEmitter.ee.once.req (/app/node_modules/got/index.js:230:20)
at Object.onceWrapper (events.js:254:19)
at EventEmitter.emit (events.js:164:20)
at Immediate.setImmediate (/app/node_modules/got/index.js:265:8)
at runCallback (timers.js:773:18)
at tryOnImmediate (timers.js:734:5)
at processImmediate [as _immediateCallback] (timers.js:711:5)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1. If I set the $ git diff HEAD~1
diff --git c/lib/manager/npm/registry.js w/lib/manager/npm/registry.js
index ec5531c..34a06ee 100644
--- c/lib/manager/npm/registry.js
+++ w/lib/manager/npm/registry.js
@@ -55,6 +55,7 @@ async function getDependency(name) {
cache: map,
json: true,
headers,
+ agent: ``,
})).body;
// Determine repository URL
let repositoryUrl; I also tried removing the I have not tried #429, but I assume that because it checks for |
Thanks for the extra info @destroyerofbuilds. Is it only a certain url/scenario that gives you the error or does it always occur unless you add I'm limited on how much time I can spend on OSS at the moment, however this is high on my list of OSS priorities so hopefully will get a chance to look further into this very soon. |
The URLs are all requests to an Artifactory deployment that's acting as a proxy to the npm registry. The URL requests are of the form: I haven't been able to figure out which request is actually causing the crash (Requests are in parallel, and I can't reproduce this issue myself locally; only seeing this issue in a server environment) |
I can reproduce this in a NodeJS OAuth Secured API that uses the OpenId-Client Library which in turn uses GOT. The API makes introspection calls to validate received tokens. The problem only occurs when I want to view these HTTPS requests in a debugger (Fiddler or Charles), in which case my code needs to configure an agent: if (process.env.HTTPS_PROXY) { That is, any developer running a server side process that uses GOT is unable to look at HTTP(S) calls, which of course is a common requirement when developing.
Looking at code, the req.connection object is always null when running Fiddler or Charles:
So it feels like the earlier suggestion to check whether req.connection is present would be useful for server side usage also. My code is available here by the way, and is a referred to in a blog I'm writing. Other that that GOT is a very nice library - but for now I'm using an old version of OpenId-Client to work around the problem. |
As soon as The following URLs had undefined connection properties:
I ran the following code through a tight loop (1000 simultaneous requests) to see if I could replicate the issue: got(`http://artifactory.example.com/artifactory/api/npm/npm/watchify`, {
json: true,
headers: {},
}); The options passed to So far I haven't been able to replicate the issue using the code above. I also discovered that I only encounter this issue when using Renovate and an Artifactory proxy. I cannot replicate this issue using Renovate and the standard npm registry. |
@sindresorhus This is obviously causing a lot of problems for people. I'd recommend we merge #429 to suppress the issue. It will stop the errors but obviously progress events will not work in these scenarios. I would like to spend more time in the future to figure out exactly why My gut feeling is that certain proxy agents are manipulating/recreating If that's the case it may even be that #429 is the only valid solution and we should just document that progress events won't work with some proxy agents. |
haven't checked this in awhile but thanks to everyone who worked on it! |
Just to say that this is fixed and using Fiddler / Charles in the latest version is fine - great work guys |
I'm seeing this problem :( I'm using babel-node/fastify, connecting to mysql db using mysql2. Everything is running off of localhost. npx clinic doctor --autocannon -- ./node_modules/.bin/babel-node server/index.js
/Users/rwlaschin/Work/Wholosophy/wholosophy-web/node_modules/on-net-listen/index.js:14 TypeError: Cannot read property 'once' of null |
@rwlaschin This doesn't look like a Got issue 🤔 |
I'm attempting to use
got
from the browser withbrowserify
. Looking through the issues I see others have had success, but I'm currently getting an error when using it. My request completes with the correct respsonse but an error come with it.The code is a fairly simple example.
I'm running this command to make my
bundle.js
fileHave I done something incorrectly?
The text was updated successfully, but these errors were encountered: