Skip to content
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

File event has not been triggered with nuxt 3 #352

Open
HenriqueAurelio opened this issue Feb 15, 2024 · 5 comments
Open

File event has not been triggered with nuxt 3 #352

HenriqueAurelio opened this issue Feb 15, 2024 · 5 comments
Labels

Comments

@HenriqueAurelio
Copy link

image

My code is like this and I already used bus boy on nuxt 2 and express, but as you can see it on the screenshot the file event doesnt trigg

@mscdex
Copy link
Owner

mscdex commented Feb 15, 2024

Perhaps the request is using different headers for files. Beyond that, there's not much I can suggest. You'd have to ask on the nuxt project issue tracker or wherever.

@HenriqueAurelio
Copy link
Author

Yea it was some different implementation on frontend thx, is there a way to check if the busboy found a error on receveing the file? Like a error listener event? Or I would have to send the size of file on body of the request and compare with size of file written after some time? Im saying after some time , because i tried to stop a request in the middle and didnt trigger the finish event listener.

@mscdex
Copy link
Owner

mscdex commented Feb 17, 2024

There would be no error unless you closed the busboy instance early for example. busboy does not inspect the data or anything like that.

If you want to handle either case, whether the form parsing was successful or not, you should be listening for the 'close' event instead. 'finish' is only emitted when the entire form was parsed successfully.

@HenriqueAurelio
Copy link
Author

But like if the latency or there is some package loss in the middle of uploading the close event would catch that moment?

@mscdex
Copy link
Owner

mscdex commented Feb 17, 2024

Measuring latency is outside of the scope of this module. Packet loss is only a thing if you're using an unreliable transport, which is unlikely, even with something like HTTP/3.

A 'close' event will be emitted if the form data is malformed, including if you busboy.end() early. It will also be emitted if the form data was parsed completely and successfully. Use it when you want to do something whether parsing was successful or not. Use 'finish' only if you want to do something when the parsing was successful. Use 'error' if you want to detect when there is an error, this will then be followed by the 'close' event.

These events follow that of typical node.js streams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants