Replies: 2 comments 6 replies
-
Hello @D-Marc1 Can you please share this code as a repo since I am not able to reproduce it by directly copy/pasting the code |
Beta Was this translation helpful? Give feedback.
-
It hangs for me when I throw an error in the partHandler callback. Im debugging the node_modules execution and the code gets through the reportError function in PartHandler. public async upload({ request, params, response }: HttpContextContract) {
try {
const { proposalId } = params
// // extra overhead writing directly to tmp storage; however this validates file types
// const file = request.file('file', { size: '20mb', extnames: ['pdf', 'doc', 'docx'] })
// console.log('file', file.tmpPath)
// if (file.hasErrors) {
// return { state: 'error', errors: file.errors }
// }
// const tmpFileStream = await Drive.use('local').getStream(file.tmpPath)
// console.log('tmpFileStream', tmpFileStream)
// const s3Results = await Drive.use('s3').putStream(`${Env.get('S3_FILEPREFIX')}/${proposalId}/${uuidv4()}/${file.fileName}`, tmpFileStream)
// console.log('file', file.hasErrors)
let s3Results
request.multipart
.onFile(
'file',
{
size: '20mb',
extnames: ['pdf', 'doc', 'docx'],
},
async (part, reportChunk) => {
throw new Error('blow up the stream')
})
await request.multipart.process()
// hangs on process
} It also hangs with pause the stream bit as well:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using file streaming, which works perfectly, other than when I try to add validations and a validation fails. I followed the docs and here's the code I'm using:
There's no issues with this this if I upload a
.png
for instance, as it obviously won't break the validation. However, if I do something specifically to break the validation, like upload a.jpg
, which isn't on theextnames
, then it starts causing issues, like the server just hanging.I do something like following for the error message:
What's weird is that when I add breakpoints, I can clearly see the message is there. However, I experience two types of issues with related behaviors. With some images, it successfully returns the response on the first time I upload a file, but then just hangs on every subsequent upload. With other images, it hangs immediately on the first upload. This behavior is consistent with the exact photo I use. Like I said, I clearly see the error message when I debug my code, but ultimately, I get the hanging issue if a file validation fails.
Beta Was this translation helpful? Give feedback.
All reactions