when middleware meet setTimeout, ctx.body don't work ?
See original GitHub issueapp.use((ctx, next) => {
console.log('1')
setTimeout(function(){
console.log('2')
return next().then(() => {
// after
console.log('3')
})
}, 1000)
});
// response
app.use(ctx => {
console.log('业务逻辑处理')
ctx.body = 'i am body'
});
when visit
$ curl http://127.0.0.1:3000
Not Found%
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Respond to Koa request immediately, continue middleware ...
The server hitting my endpoint has very strict requirements about webhook response time, and I have heavy (very heavy) work to be done...
Read more >Timers in Node.js
The timeout interval that is set cannot be relied upon to execute after that exact number of milliseconds. This is because other executing...
Read more >Make resilient Go net/http servers using timeouts, deadlines ...
If the operation does not complete in the given time limit, a timeout occurs, and the operation is canceled. Initializing a net/http server ......
Read more >API Reference: ApolloServer - Apollo GraphQL Docs
A key-value cache that Apollo Server uses to store previously encountered GraphQL operations (as DocumentNode s). It does not store query results.
Read more >middleware - Go Packages
Compress is a middleware that compresses response body of a given ... ctx after a given timeout and return a 504 Gateway Timeout...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should return Promise in middleware
Much better with async await:
random your mum joke