graysonhicks / gatsby-plugin-remote-images

:floppy_disk: A Gatsby.js plugin for downloading and linking remote images from another node's field for the benefits of gatsby-image.
155 stars 39 forks source link

Occasional Error now constant, RequestError: connect ETIMEDOUT #65

Open justintaylor-dev opened 3 years ago

justintaylor-dev commented 3 years ago

I used to run into this error occasionally when building assets from Sanity in the past, and resetting my internet connection fixed the issue, however now I run into this constantly and can't complete a build:

` ERROR

gatsby-plugin-remote-images ERROR: failed to process https://cdn.sanity.io/images/path/to/url.jpg RequestError: read ECONNRESET`

or sometimes it reads:

RequestError: connect ETIMEDOUT [ip.address...]

and sometimes:

TimeoutError: Timeout awaiting 'request' for 30000ms

I've tried increasing my retry limits and timeout env vars but that didn't help:

GATSBY_STALL_RETRY_LIMIT=30 GATSBY_STALL_TIMEOUT=100000000 GATSBY_CONNECTION_RETRY_LIMIT=40 GATSBY_CONNECTION_TIMEOUT=100000000

Does anyone else have a workaround for this?

Thanks!

justintaylor-dev commented 3 years ago

Update: I tested the same build on the internet at my work, and I no longer run into that issue. My internet at home is 47/21Mbps and at work is 912/415Mbps.

So I'm guessing if I'm trying to download too many large files it will fail on a slower connection. Is there any way to extend the timeout for this plugin specifically?

Thanks

tizzle commented 2 years ago

Same here, this problem gets more frequent, the more images you try to download. Can the timeout be set/changed as suggested by @justintaylor-dev?

graysonhicks commented 2 years ago

Working to implement this here:

https://github.com/graysonhicks/gatsby-plugin-remote-images/tree/feature/timeouts

Is based on WP plugin usage, although will be much simpler: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-remote-file-node/index.js

I think it is working as is, but Jest + env vars + setTimeout, something isn't letting me write a failing test.

Releasing it as a beta here: gatsby-plugin-remote-images@3.3.0-beta.0

Would love those that have been seeing it to try it out on your own feature branches and let me know if it helps, breaks worse, etc.

Thanks!