You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
So I am trying to implement an endpoint on my server that would pass the incoming data to a File write stream and save it to GCS, and I want to halt the upload if during streaming file turns out to be bigger than expected. Here's a snippet of how it is implemented:
constMAX_TRANSACTION_IMAGE_SIZE_BYTES=10*1024*1024;asyncfunctiontest(body: NodeJS.ReadableStream){letreceivedBytes=0;constcancelStream=newAbortController();constbucketName='bucket';constfile=this.storage.bucket(bucketName).file('image.png').createWriteStream();constvalidateStream=newPassThrough();validateStream.on('data',(chunk)=>{receivedBytes+=chunk.length;if(receivedBytes>MAX_TRANSACTION_IMAGE_SIZE_BYTES){// this correctly aborts everything in a pipeline, and destroys the streams, but// the underlying streams still seem to hangcancelStream.abort(newPayloadTooLargeException('Image too large'));}});awaitpipeline(body,validateStream,file,{signal: cancelStream.signal,});}
I have checked the code and I see that calling .destroy() on the returned write stream does not really result in anything being passed to the underlying emitStream or writeFileStream, so they stay hanging. Is this a bug on the SDK side? Is there a way to abort the upload request?
Environment details
@google-cloud/storageversion: 7.6.0Steps to reproduce
So I am trying to implement an endpoint on my server that would pass the incoming data to a File write stream and save it to GCS, and I want to halt the upload if during streaming file turns out to be bigger than expected. Here's a snippet of how it is implemented:
I have checked the code and I see that calling
.destroy()on the returned write stream does not really result in anything being passed to the underlyingemitStreamorwriteFileStream, so they stay hanging. Is this a bug on the SDK side? Is there a way to abort the upload request?