Skip to content
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 error: The header content contains invalid characters #353

Closed
pietermees opened this issue Aug 4, 2017 · 10 comments
Closed

Uncaught error: The header content contains invalid characters #353

pietermees opened this issue Aug 4, 2017 · 10 comments

Comments

@pietermees
Copy link
Contributor

I've been seeing occasional uncaught exceptions:

Uncaught error: TypeError: The header content contains invalid characters 
   at get (/var/app/current/node_modules/got/index.js:49:18) 
   at Immediate.setImmediate (/var/app/current/node_modules/got/index.js:124:3)

Scanning the code it seems that errors thrown directly by http.request or https.request on that line are not caught.

This is happening on a server that processes a very large number of http requests and I haven't been able to track down which requests cause this error.

@sindresorhus
Copy link
Owner

sindresorhus commented Aug 5, 2017

What exact version of Got do you have installed and how are you using it (Promise API or Streaming)?

@sindresorhus
Copy link
Owner

@pietermees
Copy link
Contributor Author

pietermees commented Aug 5, 2017 via email

@sindresorhus
Copy link
Owner

I think this is fixed in master. Could you try running master?

I could reproduce the unhandled exception when I put a throw statement in 7.1.0 here:

got/index.js

Line 48 in b725ef5

When I did the same in master, it was handled, since we now correctly catch and propagate errors:

got/index.js

Lines 258 to 260 in 8b040af

.catch(err => {
ee.emit('error', err);
});

@pietermees
Copy link
Contributor Author

When I update to the latest commit on master and run my test suite, the process never exits and I'm getting a (node:56384) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added. Use emitter.setMaxListeners() to increase limit warning.

Could it be that some sort of memory leak was introduce in the master codebase since 7.1.0?

@sindresorhus
Copy link
Owner

sindresorhus commented Aug 7, 2017

Not sure. Usually, that warning is just an annoying false positive though. Try to reduce your test suite until it runs again to narrow down what's causing it.

@pietermees
Copy link
Contributor Author

pietermees commented Aug 7, 2017 via email

@pietermees
Copy link
Contributor Author

I've been able to replicate this in my load tests. It seems that more and more listeners are added somewhere in the code and not cleaned up. Could it be that if a request fails some listeners are not removed?

Could this be somehow related to me using agentkeepalive to reuse sockets? Others might not be running into this if sockets are not being reused for thousands of requests?

@petitchevalroux
Copy link
Contributor

@pietermees as stated in #382 original issue seems ok in master branch

I get the MaxListenersExceededWarning warning too on connect and request event but it may be better to open a new issue

@pietermees
Copy link
Contributor Author

@petitchevalroux seems like @timdp opened up a new issue for the memory leak
I'll close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants