-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs): Use Vercel's
waitUntil
to defer freezing of Vercel La…
…mbdas (#12133) Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
- Loading branch information
Showing
12 changed files
with
57 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { GLOBAL_OBJ } from '@sentry/utils'; | ||
|
||
interface VercelRequestContextGlobal { | ||
get?(): { | ||
waitUntil?: (task: Promise<unknown>) => void; | ||
}; | ||
} | ||
|
||
/** | ||
* Function that delays closing of a Vercel lambda until the provided promise is resolved. | ||
* | ||
* Vendored from https://www.npmjs.com/package/@vercel/functions | ||
*/ | ||
export function vercelWaitUntil(task: Promise<unknown>): void { | ||
const vercelRequestContextGlobal: VercelRequestContextGlobal | undefined = | ||
// @ts-expect-error This is not typed | ||
GLOBAL_OBJ[Symbol.for('@vercel/request-context')]; | ||
|
||
const ctx = vercelRequestContextGlobal?.get?.() ?? {}; | ||
ctx.waitUntil?.(task); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters