-
Notifications
You must be signed in to change notification settings - Fork 367
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
CONTENT_DOWNLOAD_MISMATCH on prematurely closed streams #69
Comments
Thanks for the reproduction case! I have received the error from the test, and will be looking into it. |
A quick question about:
When the upstream proxy closed the socket, did you get an error event? I believe the right thing to do at that point is to close the GCS stream by calling Alternatively, this can be handled for you by using pumpify: pumpify(sourceStream, brake(10), targetStream)
.on('error', err => {
// err === expected error about the socket breaking.
// sourceStream (the GCS stream) was auto-closed
}) |
I am using pump already to handle the piping. When the situation occurs, Since we're piping directly to the end-user HTTP response, there really isn't any good way to retry the fetch, so I've simply disabled the validation as there's really nothing I can do when this situation occurs - even if it was an actual content mismatch. I still thought you might want to check if there is something you can do on your end to stop the error from being emitted, but I couldn't manage to reproduce the case 100% - using It seems determining premature closed streams is non-trivial. |
It still seems like there should only be one error emitted since you're using |
We have the same issues. We create a readstream and we only started getting these errors since updated to latested version of |
Could you provide reproduction code? When you get an error from any other stream, the GCS stream needs to be ended as well. |
Seems like we are experiencing same that we can only reproduce it when it is in a docker container in the google kubernetes container, it always seems to happen with the same file. (96.03 KB size). somehow it seems to happen differently on different clients so i'm wondering if it might have to do with chunking. also we have the same issue if we pipe createReadStream() through a transform:
i was able to get rid of this error by first reading stream till end and then reading it manually into a new stream. (bit of a work around but it worked). |
Can't seem to reproduce it now :/ it seems to happen only when an OPH scanner requests (directly over TCP socket). but i wonder how this can influence the google library to throw this error. this is what we do with the readstream:
(this code is from lib: https://github.com/nodeftpd/nodeftpd) |
@joelharkes @rexxars any updates on how this is going / reproduction code? |
Sorry, we were using as port of a relatively large and complex application and I found it hard to reproduce in an isolated fashion. Having said that, I find Node streams notoriously hard to get right, so I can't rule out that I was doing something wrong. We disabled the verification, since there's no way to retry the request when piping directly to an HTTP response. Sorry I can't be of more help here. |
Idem, we had:
The first we fixed by downgrading to storage version 1.2 Couldn't find the source problem debugging through the node modules. Maybe it's one of the sub dependencies. |
That is definitely true. Feel free to ping me if you ever need an extra set of eyes on a problem. I'm going to close this issue for now, because as said above, streams are hard to get right, and the blame could be one of many different points in an application, making it very hard to debug. If it's possible to create a reproduction case, I'll be happy to keep digging. |
Hey @stephenplusplus I get the same with a cloud function where I react to upload events and try to append files to a zip in the bucket. |
@DavideArgellati would you mind opening a new issue with reproduction code I can try? |
Cool good to know there is a 5000ms second timout that was removed. We also found that downloading and uploading the same file at the same time. could create this message. Downloads where done with streams and by clients with slower connections and small buffers. changing the upload schedule seemed to have reduced/removed these problems. |
I am getting CONTENT_DOWNLOAD_MISMATCH every time I upload and download an image. Using the completely vanilla upload and download samples here: I try with any non-image file => always works. I thought maybe I need to set contentType explicitly, so I followed This is super vanilla setup, no concurrency. Running on Electron on OSX. Does anyone know what could be the problem here? |
By the way the download is actually succeeding, in that the correct file is getting saved to disk. So this is just a false positive. |
Issue
When you use the
bucket.file(...).createReadStream()
and pipe it to a target target stream, and that target stream is ended/closed before the Google Cloud Storage client is finished reading the remote file, the validation fails because it tries to compare the partially received data with the remote hash.I've created a repository containing a simplified example of the problem. In the real-world, we experienced this problem when an HTTP server behind a reverse proxy was piping from GCS to the HTTP response, and the upstream proxy closed the socket.
Environment details
Steps to reproduce
git clone git@github.com:rexxars/gcs-premature-eos-error.git
cd gcs-premature-eos-error
npm install
test.js
directly):GCS_KEY_PATH
- Path to a Google Cloud key file with access to a bucketGCS_BUCKET
- Name of Google Cloud Storage bucket to fetch fromGCS_FILE_PATH
- Path to a file inside of the bucketnpm test
After 60 seconds, the script will exit with the following error:
The text was updated successfully, but these errors were encountered: