(task: Promise<unknown>)
| 16 | * Vendored from https://www.npmjs.com/package/@vercel/functions |
| 17 | */ |
| 18 | export function vercelWaitUntil(task: Promise<unknown>): void { |
| 19 | // We only flush manually in Vercel Edge runtime |
| 20 | // In Node runtime, we use process.on('SIGTERM') instead |
| 21 | if (typeof EdgeRuntime !== 'string') { |
| 22 | return; |
| 23 | } |
| 24 | const vercelRequestContextGlobal: VercelRequestContextGlobal | undefined = |
| 25 | // @ts-expect-error This is not typed |
| 26 | GLOBAL_OBJ[Symbol.for('@vercel/request-context')]; |
| 27 | |
| 28 | const ctx = vercelRequestContextGlobal?.get?.(); |
| 29 | |
| 30 | if (ctx?.waitUntil) { |
| 31 | ctx.waitUntil(task); |
| 32 | } |
| 33 | } |
no test coverage detected