Skip to content

Commit ef71acd

Browse files
committed
fix: handle non promise and promise-like values for waitUntil
1 parent aeb29ba commit ef71acd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/_utils.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,16 @@ function resolveCertOrKey(value?: unknown): undefined | string {
100100
}
101101

102102
export function createWaitUntil() {
103-
const promises = new Set<Promise<any>>();
103+
const promises = new Set<Promise<any> | PromiseLike<any>>();
104104
return {
105-
waitUntil: (promise: Promise<any>): void => {
105+
waitUntil: (promise: Promise<any> | PromiseLike<any>): void => {
106+
if (typeof promise?.then !== "function") return;
106107
promises.add(
107-
promise.catch(console.error).finally(() => {
108-
promises.delete(promise);
109-
}),
108+
Promise.resolve(promise)
109+
.catch(console.error)
110+
.finally(() => {
111+
promises.delete(promise);
112+
}),
110113
);
111114
},
112115
wait: (): Promise<any> => {

0 commit comments

Comments
 (0)