test(http): interaction signal listener 정리도 고정한다
문제 실행기는 호출자·interaction·scope 세 signal에 abort listener를 달고 끝날 때 셋을 모두 지운다(src/adapters/http/http-execution-v3.ts:662-664). listener 정리 테스트는 호출자와 scope signal만 감시해서, interaction signal 쪽 제거 줄(:663)을 지운 변이 R2b가 107파일 995개를 모두 통과했다. 한 interaction 안에서 요청을 여러 번 보내면 요청마다 listener 하나(lifetime controller를 잡은 closure)가 interaction 마감까지 남는다. 고른 방법과 버린 대안 - 같은 테스트(tests/unit/http-execution-v3.test.ts)에 createExecutionContext로 만든 interaction을 넘기고, 그 cancellation.signal도 감시 목록에 넣는다. - 끝나는 경우에 "interaction cancel"을 더한다. interaction 취소는 호출자 abort와 같은 forwarder를 타지만 listener를 단 signal이 달라서 따로 본다. - 별도 테스트를 새로 만드는 안은 버렸다. 세 signal은 같은 정리 함수가 지우므로 한 테스트에서 함께 보는 편이 규칙과 맞다. 위험·한계 - 테스트만 바꿨다. 실행기 코드는 그대로다. 실제 누수량은 재지 않는다. 검증 - desktop batch에서 확인: node scripts/run-vitest.ts run tests/unit/http-execution-v3.test.ts - 변이 R2b(:663 제거)를 넣으면 세 경우 모두 "removes the listeners it added to the caller, interaction and scope signals after …"가 실패해야 한다. Refs: 1105/10-02
This commit is contained in:
@@ -761,15 +761,29 @@ describe("descriptor-driven HTTP execution lifetime", () => {
|
||||
await expect(result).resolves.toMatchObject({ kind: "CANCELLED" });
|
||||
});
|
||||
|
||||
// 1103/10-04 ②. A signal is shared by many requests (a screen, a session
|
||||
// scope). Every abort listener an execution adds to the caller's and the
|
||||
// 1103/10-04 ②, 1105/10-02. A signal is shared by many requests (a screen,
|
||||
// a session scope, one interaction that sends several requests). Every abort
|
||||
// listener an execution adds to the caller's, the interaction's and the
|
||||
// scope's signal is removed when it ends, however it ends.
|
||||
it.each(["an answer", "a caller abort"] as const)(
|
||||
"removes the listeners it added to the caller and scope signals after %s",
|
||||
it.each(["an answer", "a caller abort", "an interaction cancel"] as const)(
|
||||
"removes the listeners it added to the caller, interaction and scope signals after %s",
|
||||
async (ending) => {
|
||||
const caller = new AbortController();
|
||||
const scopeLifetime = new AbortController();
|
||||
const watched = [caller.signal, scopeLifetime.signal].map((signal) => ({
|
||||
const interaction = createExecutionContext({
|
||||
interactionId: "listener-cleanup",
|
||||
deadlineMs: 10_000,
|
||||
traffic: {
|
||||
maxPhysicalRequests: 4,
|
||||
maxRetries: 2,
|
||||
maxConcurrentRequests: 1,
|
||||
},
|
||||
});
|
||||
const watched = [
|
||||
caller.signal,
|
||||
interaction.cancellation.signal,
|
||||
scopeLifetime.signal,
|
||||
].map((signal) => ({
|
||||
add: vi.spyOn(signal, "addEventListener"),
|
||||
remove: vi.spyOn(signal, "removeEventListener"),
|
||||
}));
|
||||
@@ -784,8 +798,10 @@ describe("descriptor-driven HTTP execution lifetime", () => {
|
||||
routeId: ROUTE_ID,
|
||||
scope: { ...scope, signal: scopeLifetime.signal },
|
||||
signal: caller.signal,
|
||||
execution: interaction,
|
||||
});
|
||||
if (ending === "a caller abort") caller.abort();
|
||||
if (ending === "an interaction cancel") interaction.cancellation.cancel();
|
||||
|
||||
await expect(result).resolves.toMatchObject({
|
||||
kind: ending === "an answer" ? "SUCCESS" : "CANCELLED",
|
||||
|
||||
Reference in New Issue
Block a user