portkey-admin-mcp 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/server.js +41 -2
- package/package.json +1 -1
package/build/server.js
CHANGED
|
@@ -11572,6 +11572,21 @@ function createHttpAppRuntime() {
|
|
|
11572
11572
|
sigtermHandler = void 0;
|
|
11573
11573
|
}
|
|
11574
11574
|
}
|
|
11575
|
+
async function closeListener() {
|
|
11576
|
+
const listener = server;
|
|
11577
|
+
if (!listener?.listening) {
|
|
11578
|
+
return;
|
|
11579
|
+
}
|
|
11580
|
+
await new Promise((resolveClose, reject) => {
|
|
11581
|
+
listener.once("close", resolveClose);
|
|
11582
|
+
listener.close((error) => {
|
|
11583
|
+
if (error) {
|
|
11584
|
+
reject(error);
|
|
11585
|
+
}
|
|
11586
|
+
});
|
|
11587
|
+
listener.closeIdleConnections();
|
|
11588
|
+
});
|
|
11589
|
+
}
|
|
11575
11590
|
async function closeRuntimeResources() {
|
|
11576
11591
|
if (!closeRuntimeResourcesPromise) {
|
|
11577
11592
|
closeRuntimeResourcesPromise = (async () => {
|
|
@@ -11581,6 +11596,7 @@ function createHttpAppRuntime() {
|
|
|
11581
11596
|
clearInterval(cleanupInterval);
|
|
11582
11597
|
cleanupInterval = void 0;
|
|
11583
11598
|
}
|
|
11599
|
+
const failures = [];
|
|
11584
11600
|
try {
|
|
11585
11601
|
if (isStatefulSessionMode) {
|
|
11586
11602
|
await sessionStore.closeAll();
|
|
@@ -11592,8 +11608,25 @@ function createHttpAppRuntime() {
|
|
|
11592
11608
|
)
|
|
11593
11609
|
);
|
|
11594
11610
|
await Promise.allSettled(activeReplayOperations);
|
|
11595
|
-
}
|
|
11596
|
-
|
|
11611
|
+
} catch (error) {
|
|
11612
|
+
failures.push(error);
|
|
11613
|
+
}
|
|
11614
|
+
const storeResults = await Promise.allSettled([
|
|
11615
|
+
managedEventStore.close(),
|
|
11616
|
+
closeRateLimitStore()
|
|
11617
|
+
]);
|
|
11618
|
+
for (const result of storeResults) {
|
|
11619
|
+
if (result.status === "rejected") {
|
|
11620
|
+
failures.push(result.reason);
|
|
11621
|
+
}
|
|
11622
|
+
}
|
|
11623
|
+
try {
|
|
11624
|
+
await closeListener();
|
|
11625
|
+
} catch (error) {
|
|
11626
|
+
failures.push(error);
|
|
11627
|
+
}
|
|
11628
|
+
if (failures.length > 0) {
|
|
11629
|
+
throw failures[0];
|
|
11597
11630
|
}
|
|
11598
11631
|
})();
|
|
11599
11632
|
}
|
|
@@ -11656,7 +11689,9 @@ function createHttpAppRuntime() {
|
|
|
11656
11689
|
console.log(`
|
|
11657
11690
|
[MCP] Received ${signal}, shutting down gracefully...`);
|
|
11658
11691
|
const shutdownTimeoutMs = config.shutdownTimeout;
|
|
11692
|
+
let forced = false;
|
|
11659
11693
|
const forceExitTimer = setTimeout(() => {
|
|
11694
|
+
forced = true;
|
|
11660
11695
|
console.error(
|
|
11661
11696
|
`[MCP] Forced shutdown after ${shutdownTimeoutMs}ms timeout`
|
|
11662
11697
|
);
|
|
@@ -11673,9 +11708,13 @@ function createHttpAppRuntime() {
|
|
|
11673
11708
|
error instanceof Error ? error.message : String(error)
|
|
11674
11709
|
);
|
|
11675
11710
|
}
|
|
11711
|
+
if (forced) {
|
|
11712
|
+
return;
|
|
11713
|
+
}
|
|
11676
11714
|
if (!server) {
|
|
11677
11715
|
clearTimeout(forceExitTimer);
|
|
11678
11716
|
process.exit(exitCode);
|
|
11717
|
+
return;
|
|
11679
11718
|
}
|
|
11680
11719
|
server.close(() => {
|
|
11681
11720
|
clearTimeout(forceExitTimer);
|