@whatwg-node/server
Advanced tools
Comparing version 0.10.0-alpha-20241123133536-975c9068dde45574fcfa26567e4bab96f45d1f85 to 0.10.0-alpha-20241125124208-52a1220ca8b2a3b86a8338c8f96b80dde432e1bb
@@ -44,6 +44,7 @@ "use strict"; | ||
}); | ||
function handleWaitUntils() { | ||
return Promise.allSettled(waitUntilPromises).then(() => { }, () => { }); | ||
} | ||
disposableStack.defer(handleWaitUntils); | ||
disposableStack.defer(() => { | ||
if (waitUntilPromises.size > 0) { | ||
return Promise.allSettled(waitUntilPromises).then(() => { }, () => { }); | ||
} | ||
}); | ||
function waitUntil(promiseLike) { | ||
@@ -309,6 +310,12 @@ // If it is a Node.js environment, we should register the disposable stack to handle process termination events | ||
[disposablestack_1.DisposableSymbols.asyncDispose]() { | ||
return disposableStack.disposeAsync(); | ||
if (!disposableStack.disposed) { | ||
return disposableStack.disposeAsync(); | ||
} | ||
return (0, uwebsockets_js_1.fakePromise)(undefined); | ||
}, | ||
dispose() { | ||
return disposableStack.disposeAsync(); | ||
if (!disposableStack.disposed) { | ||
return disposableStack.disposeAsync(); | ||
} | ||
return (0, uwebsockets_js_1.fakePromise)(undefined); | ||
}, | ||
@@ -315,0 +322,0 @@ }; |
@@ -560,5 +560,6 @@ "use strict"; | ||
globalThis.process.once(event, function terminateHandler() { | ||
return Promise.allSettled([...disposableStacks].map(stack => stack.disposeAsync().catch(e => { | ||
console.error('Error while disposing:', e); | ||
}))); | ||
return Promise.allSettled([...disposableStacks].map(stack => !stack.disposed && | ||
stack.disposeAsync().catch(e => { | ||
console.error('Error while disposing:', e); | ||
}))); | ||
}); | ||
@@ -565,0 +566,0 @@ } |
@@ -5,3 +5,3 @@ /* eslint-disable @typescript-eslint/ban-types */ | ||
import { completeAssign, ensureDisposableStackRegisteredForTerminateEvents, handleAbortSignalAndPromiseResponse, handleErrorFromRequestHandler, isFetchEvent, isNodeRequest, isolateObject, isPromise, isRequestInit, isServerResponse, iterateAsyncVoid, nodeRequestResponseMap, normalizeNodeRequest, sendNodeResponse, ServerAdapterRequestAbortSignal, } from './utils.js'; | ||
import { getRequestFromUWSRequest, isUWSResponse, sendResponseToUwsOpts, } from './uwebsockets.js'; | ||
import { fakePromise, getRequestFromUWSRequest, isUWSResponse, sendResponseToUwsOpts, } from './uwebsockets.js'; | ||
// Required for envs like nextjs edge runtime | ||
@@ -41,6 +41,7 @@ function isRequestAccessible(serverContext) { | ||
}); | ||
function handleWaitUntils() { | ||
return Promise.allSettled(waitUntilPromises).then(() => { }, () => { }); | ||
} | ||
disposableStack.defer(handleWaitUntils); | ||
disposableStack.defer(() => { | ||
if (waitUntilPromises.size > 0) { | ||
return Promise.allSettled(waitUntilPromises).then(() => { }, () => { }); | ||
} | ||
}); | ||
function waitUntil(promiseLike) { | ||
@@ -306,6 +307,12 @@ // If it is a Node.js environment, we should register the disposable stack to handle process termination events | ||
[DisposableSymbols.asyncDispose]() { | ||
return disposableStack.disposeAsync(); | ||
if (!disposableStack.disposed) { | ||
return disposableStack.disposeAsync(); | ||
} | ||
return fakePromise(undefined); | ||
}, | ||
dispose() { | ||
return disposableStack.disposeAsync(); | ||
if (!disposableStack.disposed) { | ||
return disposableStack.disposeAsync(); | ||
} | ||
return fakePromise(undefined); | ||
}, | ||
@@ -312,0 +319,0 @@ }; |
@@ -537,5 +537,6 @@ export function isAsyncIterable(body) { | ||
globalThis.process.once(event, function terminateHandler() { | ||
return Promise.allSettled([...disposableStacks].map(stack => stack.disposeAsync().catch(e => { | ||
console.error('Error while disposing:', e); | ||
}))); | ||
return Promise.allSettled([...disposableStacks].map(stack => !stack.disposed && | ||
stack.disposeAsync().catch(e => { | ||
console.error('Error while disposing:', e); | ||
}))); | ||
}); | ||
@@ -542,0 +543,0 @@ } |
{ | ||
"name": "@whatwg-node/server", | ||
"version": "0.10.0-alpha-20241123133536-975c9068dde45574fcfa26567e4bab96f45d1f85", | ||
"version": "0.10.0-alpha-20241125124208-52a1220ca8b2a3b86a8338c8f96b80dde432e1bb", | ||
"description": "Fetch API compliant HTTP Server adapter", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -60,3 +60,3 @@ import type { RequestListener } from 'http'; | ||
disposableStack: AsyncDisposableStack; | ||
dispose(): Promise<void>; | ||
dispose(): Promise<void> | void; | ||
} | ||
@@ -63,0 +63,0 @@ export interface RequestLike { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152905
3264