Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/storage/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,11 @@ export class UnifiedShadow {
close(): void {
try {
this.store.close();
} catch {
// shutdown path — never throw
} catch (err) {
// shutdown path — never throw, but a swallowed close failure leaves
// the sqlite handle locked (windows EBUSY on temp-dir teardown); log
// it so the next CI red names the real culprit.
loggerLog("warn", `[storage] sidecar sqlite close failed — handle may stay locked: ${String(err)}`);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions tests/persist-guard-ownership.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ function withMode(mode: "shadow" | "legacy", name: string, fn: (dir: string) =>
const dir = mkdtempSync(join(tmpdir(), `bili-guard-own-${mode}-`));
try {
await fn(dir);
} finally {
rmrf(dir);
} catch (err) {
// A teardown EBUSY must never mask the real failure (windows win22-1
// #3498: the rmrf ladder's EBUSY replaced the actual error).
try { rmrf(dir); } catch { /* keep the original error */ }
if (prev === undefined) delete process.env.BILI_STORAGE_UNIFIED;
else process.env.BILI_STORAGE_UNIFIED = prev;
throw err;
}
rmrf(dir);
if (prev === undefined) delete process.env.BILI_STORAGE_UNIFIED;
else process.env.BILI_STORAGE_UNIFIED = prev;
}) as unknown as Promise<void>;
}

Expand Down
20 changes: 10 additions & 10 deletions tests/pi-omp-fork-adopt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ async function harness() {
await once(proxy, "listening");
const paddr = proxy.address();
assert(paddr && typeof paddr === "object");
return { dir, store, upstreamUrl, origin: `http://127.0.0.1:${paddr.port}`, close: async () => { store.cancelAll(); proxy.close(); proxy.closeIdleConnections?.(); upstream.close(); upstream.closeIdleConnections?.(); await Promise.all([once(proxy, "close"), once(upstream, "close")]); } };
return { dir, store, upstreamUrl, origin: `http://127.0.0.1:${paddr.port}`, close: async () => { store.cancelAll(); proxy.close(); proxy.closeIdleConnections?.(); proxy.closeAllConnections?.(); upstream.close(); upstream.closeIdleConnections?.(); upstream.closeAllConnections?.(); await Promise.all([once(proxy, "close"), once(upstream, "close")]); } };
}

async function seedParent(h: Awaited<ReturnType<typeof harness>>, conversationId: string) {
Expand Down Expand Up @@ -366,7 +366,7 @@ function pluginCtx(h: Awaited<ReturnType<typeof harness>>, sid: string, parentSe
};
}

test("full chain: omp lane adopts behind its own identity register (#2399 stage 2 / B-plan)", async () => {
test("full chain: omp lane adopts behind its own identity register (#2399 stage 2 / B-plan)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down Expand Up @@ -406,7 +406,7 @@ test("full chain: omp lane adopts behind its own identity register (#2399 stage
}
});

test("full chain: pi lane resolves a path-shaped parentSession header and adopts (#2399 stage 2)", async () => {
test("full chain: pi lane resolves a path-shaped parentSession header and adopts (#2399 stage 2)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down Expand Up @@ -436,7 +436,7 @@ test("full chain: pi lane resolves a path-shaped parentSession header and adopts
}
});

test("full chain: pi lane skips adoption when no parent is declared", async () => {
test("full chain: pi lane skips adoption when no parent is declared", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand All @@ -453,7 +453,7 @@ test("full chain: pi lane skips adoption when no parent is declared", async () =
}
});

test("pi lane: lineage-only child is skipped before any snapshot/fork call (#2469)", async () => {
test("pi lane: lineage-only child is skipped before any snapshot/fork call (#2469)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down Expand Up @@ -496,7 +496,7 @@ test("pi lane: lineage-only child is skipped before any snapshot/fork call (#246
}
});

test("pi lane: seeded child at the branch-length boundary still adopts (#2469)", async () => {
test("pi lane: seeded child at the branch-length boundary still adopts (#2469)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down Expand Up @@ -534,7 +534,7 @@ test("pi lane: seeded child at the branch-length boundary still adopts (#2469)",
}
});

test("pi lane: an exploding getBranch fails toward capability and still adopts (#2469)", async () => {
test("pi lane: an exploding getBranch fails toward capability and still adopts (#2469)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down Expand Up @@ -565,14 +565,14 @@ test("pi lane: an exploding getBranch fails toward capability and still adopts (
}
});

test("tryForkAdoption rejects a responses child whose prefix matches nothing (#2469 stage 2)", async () => {
test("tryForkAdoption rejects a responses child whose prefix matches nothing (#2469 stage 2)", { timeout: 60_000 }, async () => {
const { fetchImpl, calls } = fakeFetchRouting([snapshotRoute]);
const result = await tryForkAdoption({ base: "http://px", parentConversationId: "p1", childConversationId: "c1", body: { model: "gpt", input: [{ type: "message", role: "user", content: "completely unrelated" }] }, fetchImpl });
assert.deepEqual(result, { outcome: "degraded", reason: "no prefix match" });
assert.equal(calls.filter((c) => c.url.endsWith("/__bili/plugin/fork")).length, 0, "no fork receipt is posted for a mismatch");
});

test("full chain: responses-wire child adopts an openai-seeded parent (#2469 stage 2)", async () => {
test("full chain: responses-wire child adopts an openai-seeded parent (#2469 stage 2)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down Expand Up @@ -623,7 +623,7 @@ test("full chain: responses-wire child adopts an openai-seeded parent (#2469 sta
// session_start must yield only for the SAME parent declaration.
// ---------------------------------------------------------------------------

test("fork endpoint: identity-registered child yields only for the same parent (#2399 B-plan)", async () => {
test("fork endpoint: identity-registered child yields only for the same parent (#2399 B-plan)", { timeout: 60_000 }, async () => {
resetForkCapabilityCacheForTest();
const h = await harness();
try {
Expand Down
6 changes: 4 additions & 2 deletions tests/plugin-bypass.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ mitm: { enabled: false, domains: [] },
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
proxy.closeAllConnections?.();
upstream.close();
upstream.closeIdleConnections?.();
upstream.closeAllConnections?.();
await Promise.allSettled([once(proxy, "close"), once(upstream, "close")]);
},
};
Expand All @@ -89,7 +91,7 @@ afterEach(async () => {
});

describe("plugin bypass header (#920)", () => {
it("bypassed requests are forwarded verbatim — no tool injection, no nudge", async () => {
it("bypassed requests are forwarded verbatim — no tool injection, no nudge", { timeout: 60_000 }, async () => {
const body = { model: "test-model", stream: false, messages: [{ role: "user", content: "hello legacy session" }] };
const resp = await fetch(`http://127.0.0.1:${h!.proxyPort}/bili/http://127.0.0.1:${h!.upstreamPort}/v1/chat/completions`, {
method: "POST",
Expand All @@ -104,7 +106,7 @@ describe("plugin bypass header (#920)", () => {
assert.equal(h!.captured[0]!.headers["x-bili-plugin-bypass"], "1");
});

it("without the header the same request gets the plugin pipeline (tools injected)", async () => {
it("without the header the same request gets the plugin pipeline (tools injected)", { timeout: 60_000 }, async () => {
const body = { model: "test-model", stream: false, messages: [{ role: "user", content: "hello new session" }] };
const resp = await fetch(`http://127.0.0.1:${h!.proxyPort}/bili/http://127.0.0.1:${h!.upstreamPort}/v1/chat/completions`, {
method: "POST",
Expand Down
Loading
Loading