mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-04 10:10:01 +00:00
test(ci): backport concurrent MCP expiry fixture fix (#155577)
This commit is contained in:
parent
724261e7ff
commit
4cb5411237
2 changed files with 22 additions and 8 deletions
|
|
@ -305,6 +305,7 @@ async function runHttp() {
|
|||
}
|
||||
const app = createMcpExpressApp();
|
||||
const sessions = new Map();
|
||||
const pendingSessionExpirations = new Map();
|
||||
const records = new Set();
|
||||
const catalogState = { rotated: false, expiryCalls: 0 };
|
||||
const appFixtureEnabled = process.env.MCP_APP_GRANT_REVALIDATION_FIXTURE === "1";
|
||||
|
|
@ -353,14 +354,26 @@ async function runHttp() {
|
|||
const sessionId = req.headers["mcp-session-id"];
|
||||
let transport;
|
||||
if (typeof sessionId === "string") {
|
||||
if (req.body?.params?.arguments?.marker === "expire-session") {
|
||||
const marker = req.body?.params?.arguments?.marker;
|
||||
if (marker === "expire-session" || marker === "expire-concurrent-session") {
|
||||
catalogState.expiryCalls += 1;
|
||||
const pending = pendingSessionExpirations.get(sessionId) ?? [];
|
||||
pending.push({ response: res, id: req.body?.id ?? null });
|
||||
if (marker === "expire-concurrent-session" && pending.length < 2) {
|
||||
// Expire only after both calls reach this session. The first 404
|
||||
// otherwise retires the transport before the second request arrives.
|
||||
pendingSessionExpirations.set(sessionId, pending);
|
||||
return;
|
||||
}
|
||||
pendingSessionExpirations.delete(sessionId);
|
||||
sessions.delete(sessionId);
|
||||
res.status(404).json({
|
||||
jsonrpc: "2.0",
|
||||
error: { code: -32001, message: "Session not found" },
|
||||
id: req.body?.id ?? null,
|
||||
});
|
||||
for (const { response, id } of pending) {
|
||||
response.status(404).json({
|
||||
jsonrpc: "2.0",
|
||||
error: { code: -32001, message: "Session not found" },
|
||||
id,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
const record = sessions.get(sessionId);
|
||||
|
|
|
|||
|
|
@ -285,18 +285,19 @@ describe("Gateway/node MCP real-process stress", () => {
|
|||
|
||||
descriptors = (await waitForNode(gateway, nodeId, 3)).nodePluginTools ?? [];
|
||||
const streamable = descriptorFor(descriptors, "streamableHttp");
|
||||
// The fixture admits both HTTP requests before expiring their shared session.
|
||||
const expired = await Promise.allSettled([
|
||||
invokeNodeMcpPayload({
|
||||
gateway,
|
||||
nodeId,
|
||||
descriptor: streamable,
|
||||
marker: "expire-session",
|
||||
marker: "expire-concurrent-session",
|
||||
}),
|
||||
invokeNodeMcpPayload({
|
||||
gateway,
|
||||
nodeId,
|
||||
descriptor: streamable,
|
||||
marker: "expire-session",
|
||||
marker: "expire-concurrent-session",
|
||||
}),
|
||||
]);
|
||||
expect(expired.every((result) => result.status === "rejected")).toBe(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue