Comments (8)
Ah. Just curled that url. A redirect? Not supported in this library?
from node-fetch.
How do I handle this error? And is it possible to follow the redirect using fetch-node
?
from node-fetch.
Yep, node-fetch
follows redirect by default, so the problem is not the redirect itself, but somehow node.js zlib is not able to handle the deflate
response this server is returning.
https://github.com/bitinn/node-fetch/blob/master/index.js#L141
As we do test for deflate response support, my guess would be that particular server is returning something weird.
https://github.com/bitinn/node-fetch/blob/master/test/server.js#L67-L74
https://github.com/bitinn/node-fetch/blob/master/test/test.js#L329-L338
As a workaround for now, setting options compress: false
will cause the server to return decompressed content, allowing your fetch to go through.
Neverthless, I think in this case we need to handle this error so that fetch
reject the result (to truly fix the problem require checking what went wrong during zlib inflate, maybe open a ticket on node.js core?)
from node-fetch.
Thanks for your reply.
I think in this case we need to handle this error so that fetch reject the result
Yeah I think so too. As it is now I seem to have no way to handle the error, and I would prefer receive an Error rather than changing the compression mode (I'm making many requests).
to truly fix the problem require checking what went wrong during zlib inflate, maybe open a ticket on node.js core?
Not very read up on these things. How would I be able to tell what wen't wrong during the Nvm, I see that the inflate happens on the receiving end. Will do some more research. Will also try doing the same inflate
? Would I not need to get onto the server serving that url?fetch
in a browser to see what happens there.
from node-fetch.
@pocketjoso I plan to work on this module next week, will update when the fix has landed.
from node-fetch.
Awesome. :)
from node-fetch.
Fixed in v1.3.3, just note that we can't reject the fetch request (because the error is on body, which is a stream) but we do reject it when you call res.text()
or res.json()
.
Otherwise you can use res.body.on('error', handler)
to catch it independently.
from node-fetch.
Excellent, thanks for fixing!
from node-fetch.
Related Issues (20)
- When using timeout at high concurrency, I get a different result than I expected.
- TypeScript RequestInit interface missing 'duplex' HOT 12
- `node-fetch` does not work behind a proxy HOT 6
- Suggest: Align fetch function's type with the latest Typescript type on fetch function?
- node v20, closing server and re-listening between requests causes ECONNRESET HOT 3
- SSL error when setting host: header correctly HOT 1
- Node-fetch allows setting forbidden headers HOT 3
- Could not catch Premature close error HOT 1
- Broken clone() method in newer version of 3.3.* (at least)
- Critical dependency:
- failing without clear reason HOT 3
- FormData with invalid Content-Length HOT 2
- Pure ems bundle prevents node-fetch usage in libraries/frameworks HOT 2
- Can't import HOT 1
- v2.7.0: punycode is deprecated in 'whatwg-url' and 'tr46' HOT 3
- Faulty NPM upload 2.7.0 HOT 3
- The 'body' stream never ends for empty HTTP response bodies on Node 16 HOT 1
- Unhandled 'error' event when using AbortSignal to cancel requests HOT 2
- Andoka now
- bug issue
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 node-fetch.