- Notifications
You must be signed in to change notification settings - Fork611
Throttle (pause/resume) file upload#1043
-
...Synchronicity for unique file names is killing me. I'm having a hard time, with the not being able to perform any async operation before: res.onData while receiving a post. I'm setting up a file upload server, and I need to get a unique filename for my stream in an async way, there's just too much concurrency to do it any other way, is this really not feasible? :( If I perform an async operation to get fileName, then res.onData just won't perform its callback, like there's nothing there.
|
BetaWas this translation helpful?Give feedback.
All reactions
You can pause receiving withhttps://unetworking.github.io/uWebSockets.js/generated/interfaces/HttpResponse.html#pause.pause-1
But you need to buffer up spurious data either way (up to 512kb but for correctness you need to handle all spurious data). So call onData first, then call pause and when you have your filename call resume then write first your buffered up then from onData.
This library does not hide or fake behavior that would be non-technical so for this reason there still is spurious data like mentioned above (it's impossible to know, efficiently)
Replies: 2 comments 2 replies
-
You can pause receiving withhttps://unetworking.github.io/uWebSockets.js/generated/interfaces/HttpResponse.html#pause.pause-1 But you need to buffer up spurious data either way (up to 512kb but for correctness you need to handle all spurious data). So call onData first, then call pause and when you have your filename call resume then write first your buffered up then from onData. This library does not hide or fake behavior that would be non-technical so for this reason there still is spurious data like mentioned above (it's impossible to know, efficiently) |
BetaWas this translation helpful?Give feedback.
All reactions
-
FWIW, if you use this to implement throttling, even if you call |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes this is the spurious data |
BetaWas this translation helpful?Give feedback.
All reactions
-
Gotcha, thanks. |
BetaWas this translation helpful?Give feedback.