Skip to content

Commit aa0d369

Browse files
committed
test(runtime-host): cover SessionAdmissionGate.detach
The behaviour change was listed nowhere and had no test: work detached from an admission must take admissions of its own, queued behind the active one like any other caller. Generated-by: Claude Code
1 parent 7449afa commit aa0d369

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

packages/runtime-host/src/__tests__/session-admission-gate.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,28 @@ test('rejects accidental admission re-entry instead of deadlocking', async () =>
147147
);
148148
});
149149
});
150+
151+
test('work detached from an admission takes admissions of its own', async () => {
152+
const gate = new SessionAdmissionGate();
153+
const release = deferred();
154+
const order: string[] = [];
155+
let detached!: Promise<void>;
156+
157+
// The detached work starts inside the admission and admits before the
158+
// admission ends, which is the order a drained Turn reaches its first
159+
// admission in. Inherited context would reject it as re-entry.
160+
await gate.run('session', async () => {
161+
order.push('active:start');
162+
detached = gate.detach(async () => {
163+
await gate.run('session', () => {
164+
order.push('detached:admitted');
165+
});
166+
});
167+
await Promise.resolve();
168+
order.push('active:end');
169+
release.resolve();
170+
});
171+
await release.promise;
172+
await detached;
173+
assert.deepEqual(order, ['active:start', 'active:end', 'detached:admitted']);
174+
});

0 commit comments

Comments
 (0)