Luke Childs
2 years ago
commit
0c85f296ad
3 changed files with 20 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); |
|||
|
|||
export default async function handler(request, response) { |
|||
console.log('before'); |
|||
response.send('hello, world!'); |
|||
await delay(100); |
|||
// This doesn't get logged
|
|||
console.log('after'); |
|||
} |
@ -0,0 +1,6 @@ |
|||
export default function handler(request, response) { |
|||
console.log('before'); |
|||
response.send('hello, world!'); |
|||
// This gets logged
|
|||
console.log('after'); |
|||
} |
@ -0,0 +1,5 @@ |
|||
# Vercel Bug |
|||
|
|||
It seems that when a response is sent Vercel makes the assumption that everything is finished and prematurely kills an async handler instead of waiting for the Promise to resolve. This means any work deferred to the next tick after the response is sent will not be completed. |
|||
|
|||
I think this is a bug, it's inconsistent with how synchronous handlers work and I would intuitively expect that if a handler returns a Promise, that Vercel would wait for that Promise to resolve before killing the process. |
Loading…
Reference in new issue