Comments (6)
Holy shmoly. I'll take a look at this ASAP.
from needle.
I think the problem lies with the server responding with a Content-Length of 0 bytes. That makes the parse error occur at the socket level, not at the JSON.parse() level:
Error: Parse Error
at Socket.socketOnData (http.js:1583:20)
at TCP.onread (net.js:527:27)
I'm not sure how we should handle this. I could skip the error if its code equals 'HPE_INVALID_CONSTANT', and you would get an empty buffer as a response. What do you think?
from needle.
Personally i don't mind getting an error ( any error ) while i won't get the second callback it's fine.
But i'm not a fan of hardcoding stuff, better build a simple mechanism to keep track when a callback was fired ( like making callback = null or fired = true etc ) , because i'm not sure if HPE_INVALID_CONSTANT
is the only case.
In the web scrapers world things are scary.
from needle.
Yeah, I know (been there). Needle's point is to make it easy for developers, so I guess we should handle this case in a better way. After all, what everyone cares for is the data, not if the data's full length matches what the Content-Length header says.
from needle.
On second thought, and after reading about the HPE_INVALID_CONSTANT error, we're not handling that error code because it may occur for other reasons as well, such as the response not having an HTTP header. I think it's too dangerous to not trigger this error if the HTTP parser raises it.
I just pushed an updated version that does check whether the callback was fired or not, though, so you shouldn't get the callback fired twice now. I'm closing this issue but feel free to reopen it if you spot any other weirdness. :)
from needle.
Thanks, i'll do that tomorrow.
from needle.
Related Issues (20)
- Very infrequent TypeError: iconv.encodingExists is not a function
- Tunnelling doesn't work in v3.1.0 HOT 12
- Proposal: Supporting User-Defined "Follow If" Conditions
- Piping needle request to Express response won't set the correct headers
- Multiple Files Upload Renames Input Field
- Uncaught asynchronous error
- Remote end closed socket abruptly errors HOT 2
- a ':' in nonce breaks digest authentication HOT 1
- Digest MD5 not working with Geovision IP Camera
- Uncaught ECONNRESET exception
- needle.get cannot guaranty getting the http stream HOT 2
- FEATURE: Retry HOT 1
- follow_set_cookies -> not working!!!
- Bug in 3.3.0: accidental creation of `global.signal`, gets caught in strict UTs
- README recommends mikeal's request HOT 3
- Multipart uploads strips date values in the request body HOT 2
- Doesn't work in Cloudflare Workers HOT 1
- Sorry, I was about to post this issue to a different repo, don't even know how it happened that I posted it here
- `get` with redirect leads to ~30sec hang HOT 7
- Invalid protocol causes uncatchable error in node:http(s)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from needle.