Is it possible to use asynchronous functions in/as http handlers? #50
-
This code causes server to terminate: app.get('/*', async (res) => {
res.end(await someFunc());
}); |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
You have two problems here - you can't return from a handler without responding OR attaching an abort handler, just like the message you got says. This message probably needs to be simplified, but it should terminate. Second, it is now possible to use async/await as per last commit, I tested it and it works. |
Beta Was this translation helpful? Give feedback.
-
This could use an example - AsyncFunction.js or something |
Beta Was this translation helpful? Give feedback.
-
I have added an example for this. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot! It’s very good to see, that library is under active development 🥳 |
Beta Was this translation helpful? Give feedback.
-
I sure hope so. First "public" release was 5 days ago 😉 |
Beta Was this translation helpful? Give feedback.
You have two problems here - you can't return from a handler without responding OR attaching an abort handler, just like the message you got says. This message probably needs to be simplified, but it should terminate.
Second, it is now possible to use async/await as per last commit, I tested it and it works.