Giter VIP home page Giter VIP logo

Comments (8)

pocketjoso avatar pocketjoso commented on May 22, 2024

Ah. Just curled that url. A redirect? Not supported in this library?

from node-fetch.

pocketjoso avatar pocketjoso commented on May 22, 2024

How do I handle this error? And is it possible to follow the redirect using fetch-node?

from node-fetch.

bitinn avatar bitinn commented on May 22, 2024

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.

pocketjoso avatar pocketjoso commented on May 22, 2024

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 inflate? Would I not need to get onto the server serving that url? Nvm, I see that the inflate happens on the receiving end. Will do some more research. Will also try doing the same fetch in a browser to see what happens there.

from node-fetch.

bitinn avatar bitinn commented on May 22, 2024

@pocketjoso I plan to work on this module next week, will update when the fix has landed.

from node-fetch.

pocketjoso avatar pocketjoso commented on May 22, 2024

Awesome. :)

from node-fetch.

bitinn avatar bitinn commented on May 22, 2024

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.

pocketjoso avatar pocketjoso commented on May 22, 2024

Excellent, thanks for fixing!

from node-fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.