mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 03:33:25 +00:00
fix(server): report unconfirmed HTTP response cleanup as a cleanup error (#10719)
NodeHttpRequestOwner.drain() reported a failed response-source finalizer as a transport resource constraint, which reads as a budget the caller could raise. It is retained cleanup, so drain now throws a ProviderCleanupError with cleanupIncomplete and the retained resource, and the file leaves the typed-resource-refusal baseline.
This commit is contained in:
1 parent
79cc07ecf1
commit
d1e2a261f8
3 files changed
+19
-13
No files matched your search
@@ -7,6 +7,5 @@
|
||||
"src/model/ModelArtifactProvider.ts": 1,
|
||||
"src/native/NativeMacOSProvider.ts": 1,
|
||||
"src/native/NativePlistSource.ts": 1,
|
||||
"src/server/http/NodeHttpRequestOwner.ts": 1,
|
||||
"src/sqlite/SqliteDatabaseWorkerExecution.ts": 1
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import type { IncomingMessage, ServerResponse } from "node:http";
|
||||
|
||||
import { writeWebResponse } from "./nodeHttpBridge.js";
|
||||
import { AnalysisResourceConstraintError } from "../../domain/analysisErrorCore.js";
|
||||
import { ProviderCleanupError } from "../../domain/providerCleanupError.js";
|
||||
|
||||
const HTTP_RESPONSE_SOURCE = "MCP HTTP response source";
|
||||
|
||||
export type HttpAdmissionLifetime = "dispatch" | "response";
|
||||
|
||||
@@ -162,17 +164,21 @@ export class NodeHttpRequestOwner {
|
||||
while (this.#bodyCleanups.size > 0)
|
||||
await Promise.allSettled(this.#bodyCleanups);
|
||||
if (this.#cleanupFailures.length > 0)
|
||||
throw new AnalysisResourceConstraintError(
|
||||
"mcp_http_response_cleanup",
|
||||
"transport",
|
||||
"HTTP response cleanup could not be confirmed; provider shutdown remains blocked",
|
||||
{ failed_cleanup_count: this.#cleanupFailures.length },
|
||||
// Unconfirmed cleanup is retained work, not a budget the caller can raise.
|
||||
throw new ProviderCleanupError(
|
||||
"rea",
|
||||
[HTTP_RESPONSE_SOURCE],
|
||||
{
|
||||
reason:
|
||||
"HTTP response cleanup could not be confirmed; provider shutdown remains blocked",
|
||||
failed_cleanup_count: this.#cleanupFailures.length,
|
||||
},
|
||||
{
|
||||
operation: "mcp_http_response_cleanup",
|
||||
cause: new AggregateError(
|
||||
this.#cleanupFailures,
|
||||
"Response cleanup failed",
|
||||
),
|
||||
retryable: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import { mcpAllowedHostsTextSchema } from "../../config/mcpHttpEndpoint.js";
|
||||
import { parseMcpHttpArguments } from "../../main/mcpHttpArguments.js";
|
||||
import { RequestTrackingMcpServer } from "../RequestTrackingMcpServer.js";
|
||||
import { waitFor } from "../../../tests/support/testWait.js";
|
||||
import { ProviderCleanupError } from "../../domain/providerCleanupError.js";
|
||||
|
||||
const servers: StreamableHttpServer[] = [];
|
||||
|
||||
@@ -1408,13 +1409,13 @@ it("retains failed response cleanup and blocks provider teardown and further adm
|
||||
expect((await fetch(new URL("/health", served.url))).status).toBe(503);
|
||||
});
|
||||
await expect(served.prepareShutdown()).rejects.toMatchObject({
|
||||
_tag: "AnalysisResourceConstraintError",
|
||||
reportedLimits: { failed_cleanup_count: 1 },
|
||||
_tag: "ProviderAdapterError",
|
||||
cleanupIncomplete: true,
|
||||
cleanupResources: ["MCP HTTP response source"],
|
||||
diagnostics: { failed_cleanup_count: 1 },
|
||||
cause: expect.any(AggregateError),
|
||||
});
|
||||
await expect(served.close()).rejects.toMatchObject({
|
||||
reportedLimits: { failed_cleanup_count: 1 },
|
||||
});
|
||||
await expect(served.close()).rejects.toBeInstanceOf(ProviderCleanupError);
|
||||
expect(shutdownHooks()).toBe(0);
|
||||
await expect(rawHttpRequest(new URL(served.url))).rejects.toMatchObject({
|
||||
code: "ECONNREFUSED",
|
||||
|
||||
Reference in new issue
Block a user