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

express compatiablity, early exit, streaming responses #30

Open
neimanpinchas opened this issue May 13, 2024 · 0 comments
Open

express compatiablity, early exit, streaming responses #30

neimanpinchas opened this issue May 13, 2024 · 0 comments

Comments

@neimanpinchas
Copy link

I found a few diverts from node express, I wonder what was the design desicion, maybe this issue could be a place to discuss their need and usage.

While working on my cors PR I found that there is no way to signal in middleware that I am done processing and stop the workflow this might be usefull to restrict users, for preflight requests etc.

In node express there is the optional next callback that could be used to asynchronous signal that it is time for the next middleware, so we have the choice to end the response and never call it.
We could negate the workflow and give a response.end method to positivly signal to stop processing rules, to get the same effect, the express way is a benefit for async workflows.

Also I see that res.end is private, and res.send is calling end implicitally from sendBytes, I am happy with this desicion, as it was very common in express to forget to res.end (in try catch) and than cause the machine to exhusted all tcp connections, but on the other hand this is forcing us to keep in RAM the whole response while acummelating, (and need to use a StringBuf for efficient concatenation).

We can also solve this one with negetive logic, by giving an option to turn off implicit ending, or adding a res.write that doesn't close the connection.

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

No branches or pull requests

1 participant