Closed raviradadiya0142 closed 3 weeks ago
error Error: Failed to upload file: Cannot call write after a stream was destroyed
at Writable.
@raviradadiya0142 how frequently are you running into this problem? I'm assuming the exception gets thrown during the save
call but just want to make sure this code never actually reaches the getSignedUrl
portion, is that accurate? Any different behavior if you use resumable: true
or validation
not set to false?
Ran some tests this morning and have been unable to recreate this. If you can supply more information, please feel free to reopen.
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Node.js version : 16 "@google-cloud/storage": 7.11.3
Error during file upload NodeError: Cannot call write after a stream was destroyed 8|unipin-node-live | at doWrite (/home/unipin/unipin_nodejslive/node_modules/readable-stream/lib/_stream_writable.js:390:38) 8|unipin-node-live | at writeOrBuffer (/home/unipin/unipin_nodejslive/node_modules/readable-stream/lib/_stream_writable.js:381:5) 8|unipin-node-live | at Writable.write (/home/unipin/unipin_nodejslive/node_modules/readable-stream/lib/_stream_writable.js:302:11) 8|unipin-node-live | at HashStreamValidator.ondata (node:internal/streams/readable:809:22) 8|unipin-node-live | at HashStreamValidator.emit (node:events:517:28) 8|unipin-node-live | at addChunk (node:internal/streams/readable:368:12) 8|unipin-node-live | at readableAddChunk (node:internal/streams/readable:341:9) 8|unipin-node-live | at Readable.push (node:internal/streams/readable:278:10) 8|unipin-node-live | at HashStreamValidator._transform (/home/unipin/unipin_nodejslive/node_modules/@google-cloud/storage/build/cjs/src/hash-stream-validator.js:95:14) 8|unipin-node-live | at Transform._write (node:internal/streams/transform:175:8)
const file = cloudStorage.bucket(bucketName).file(fileName); return new Promise(async (resolve, reject) => { try { // Directly save the file content await file.save(fileData.buffer, { metadata: { contentType: fileData.mimetype, }, resumable: false, // Set to false as we're not using streams, validation:false });