Compare commits

...

2 Commits

Author SHA1 Message Date
Vercel Release Bot
9fe92d7de0 Version Packages (#11558)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/functions@1.0.1

### Patch Changes

- Don't throw error if context is missing
([`0817527f9`](0817527f9e))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-07 17:13:10 +02:00
Kiko Beats
0817527f9e [@vercel/functions]: don't throw error if context is missing (#11557)
making `waituntil` a noop
2024-05-07 17:02:23 +02:00
4 changed files with 10 additions and 15 deletions

View File

@@ -1,5 +1,11 @@
# @vercel/functions # @vercel/functions
## 1.0.1
### Patch Changes
- Don't throw error if context is missing ([`0817527f9`](https://github.com/vercel/vercel/commit/0817527f9e9d0d5fceb73f21e695089349a96d3e))
## 1.0.0 ## 1.0.0
### Major Changes ### Major Changes

View File

@@ -2,7 +2,6 @@
export const waitUntil = promise => { export const waitUntil = promise => {
if ( if (
promise instanceof Promise === false ||
promise === null || promise === null ||
typeof promise !== 'object' || typeof promise !== 'object' ||
typeof promise.then !== 'function' typeof promise.then !== 'function'
@@ -13,12 +12,5 @@ export const waitUntil = promise => {
} }
const ctx = globalThis[Symbol.for('@vercel/request-context')]?.get?.() ?? {}; const ctx = globalThis[Symbol.for('@vercel/request-context')]?.get?.() ?? {};
ctx.waitUntil?.(promise);
if (!ctx.waitUntil) {
throw new Error(
'failed to get waitUntil function for this request context'
);
}
ctx.waitUntil(promise);
}; };

View File

@@ -23,14 +23,11 @@ test.each([
}); });
test.each([null, undefined, {}])( test.each([null, undefined, {}])(
'waitUntil throws when context is %s', 'waitUntil does not throw an error when context is %s',
input => { input => {
const promise = Promise.resolve(); const promise = Promise.resolve();
globalThis[Symbol.for('@vercel/request-context')] = input; globalThis[Symbol.for('@vercel/request-context')] = input;
expect(() => waitUntil(promise)).toThrow(Error); expect(() => waitUntil(promise)).not.toThrow();
expect(() => waitUntil(promise)).toThrow(
'failed to get waitUntil function for this request context'
);
} }
); );

View File

@@ -2,7 +2,7 @@
"name": "@vercel/functions", "name": "@vercel/functions",
"description": "Runtime functions to be used with your Vercel Functions", "description": "Runtime functions to be used with your Vercel Functions",
"homepage": "https://vercel.com", "homepage": "https://vercel.com",
"version": "1.0.0", "version": "1.0.1",
"types": "index.d.ts", "types": "index.d.ts",
"main": "index.js", "main": "index.js",
"repository": { "repository": {