-
Notifications
You must be signed in to change notification settings - Fork 233
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
server hangs if a handler returns undefined #11
Comments
* includes commented-out test to match #11
Nice catch, but something i'm afraid that, is we would continue to next middleware if handle uses an async (callback based) operation like this: export default (req, res) {
db.getUser((user) => {
res.end(JSON.stringify(user))
})
} A legacy middleware like this would be broken.... I was supposing middleware (or better handle since has only two params) should always end request and so we listen to |
Very good point....! Will remove from #10 Yes, I like the simplicity of writing a handler like: app.use('/api', (req) => {
if (req.method !== 'GET') return
return data
}) ... but it's more important not to break promise-based handlers. |
I see... In that case we can introduce something like |
I would really like that, but do we lose the benefit of interop with express middleware where the user doesn't have control over each |
For a repro of hang:
Was trying (and failed) to replicate issue with #13 - but oh well, at least they add a few more tests 🤷♂️ |
Thanks for repro @danielroe! Actually it helped to find two issues:
|
with automatic promisifying, if a handler returns undefined, the promise never resolves and the server hangs...
Is there a reason we don't immediately
resolve(undefined)
if the handler does?The text was updated successfully, but these errors were encountered: