-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ReadError: The server aborted pending request #4357
Comments
I have tried to replace all this code
with this, to see if the problem is related to const http = require('node:https')
const res = await new Promise((resolve, reject) => {
const req = http.request({
method: 'POST',
host: 'content.dropboxapi.com',
path: '/2/files/download',
headers: {
Authorization: `Bearer ${token}`,
'Dropbox-API-Arg': httpHeaderSafeJson({ path: String(id) }),
},
}, (res) => {
console.log(`STATUS: ${res.statusCode}`)
console.log(`HEADERS: ${JSON.stringify(res.headers)}`)
resolve(res)
})
req.on('error', (err) => {
reject(err)
})
req.write(Buffer.alloc(0))
req.end()
})
return { stream: res } ...same problem, but the error is more familiar:
...so the bug is not in I'm not able to reproduce the problem with
and it works! good ol' curl! need to investigate more why only curl works and not node.js |
Finally I managed to identify and solve the problem! In the end I compared which HTTP headers curl sends vs headers sent by Node.js
So when I in This seems like it's not a problem with other providers like Google or Box (with the default I tried to change curl also to use
Note that it's easier to reproduce this problem with a throttled connection (e.g. Network Link Conditioner on Macos). So this must be a problem with dropbox's HTTP server, and I think we should add the I cannot explain why a VPN helps but I'm thinking VPN might batch TCP packets together differently, so that it doesn't trigger the connection reset before packets have been read. If we still have ECONNRESET issues in the future we might want to pass the data thru a Passthrough stream with a high |
* add connection: keep-alive to dropbox fixes #4357 * update a todo * dont clear screen by vite i want to also see companion's output
* add connection: keep-alive to dropbox fixes transloadit#4357 * update a todo * dont clear screen by vite i want to also see companion's output
Initial checklist
Link to runnable example
https://uppy.io/examples/dashboard/
Steps to reproduce
I'm able to reproduce the problem very consistently, it's very easy to reproduce:
If I run it locally and slow down/throttle the tcp responses it happens even with just a single file. The timeouts happen after about 30 sec or so (though not consistent timing).
The code I use to throttle locally:
Replace this line
uppy/packages/@uppy/companion/src/server/Uploader.js
Line 300 in 233435f
...with this:
Expected behavior
Uploads should complete successfully.
Actual behavior
Upload of some or all of the files fails.
Downloads from these providers are consistently failing with
ReadError: The server aborted pending request
- meaning the server abruptly disconnects Companion's http request to download the file from the provider.Here's the most interesting part:
If I vpn to the US (or Asia which I am in now) using NordVPN, the issue completely disappears. I'm not able to make a single upload fail, even with throttling enabled and multiple files!
Interestingly the problem also happens on our https://uppy.io/examples/dashboard/ - and this server runs on heroku servers in the US. At first I thought that dropbox, google etc have some DoS protection again requests coming from certain regions like asia, but that seems not to be the case.
What is my theory now is that these providers have DoS protection against certain IP address ranges, where they will be more inclined to cut off "long" running reqeusts coming from these ranges in order to protect themselves. Heroku servers and an internet cafe in Asia are both considered "unsafe" IP addresses, but nordVPN and other VPN providers' sole job is to provide customers with IP addresses that cloud providers cannot block (to watch netflix in any country for example, bypassing netflix's blocks), so using a VPN gives an IP address that providers like dropbox and google are also not able to flag and protect against.
Not sure how to solve this. I think retry is not going to help, because the problem seems very consistent, and retrying will probably just end up getting companion's IP blocked.
The text was updated successfully, but these errors were encountered: