Open leafo opened 1 year ago
onstream
fires when there is a request ready to be handled: if not even a single byte of it is read, then onstream
will fire again on the next main loop iteration.
If you haven't called get_headers
, then it hasn't even started handling the request, and as such it can't terminate the request.
The following code will loop infinitely when you make a request to the server.
onstream
andonerror
are called endlessly, the requesting client hangs. There doesn't appear to be a way to finalize the stream in the error handler based on what I've looked at so far.I would expect it to terminate the request with a 503 error, as if you had triggered an error after getting headers.
My guess that is that since the stream doesn't make any progress being processed in the stream handler before error it's re-queued to be processed again, hence the infinite loop.
Note: It's necessary to provide a custom
onerror
function, as the default one will terminate the entire server by throwing an error.