fix(pi): single-flight managed extension materialization

This commit is contained in:
2026-08-25 12:08:53 +08:00
parent 95f3d1575d
commit 7aa9f79bb2
2 changed files with 30 additions and 1 deletions

View File

@@ -35,6 +35,26 @@ async function post(
}
describe('managed Pi extension bridge', () => {
it('single-flights the shared managed extension for concurrent worker registration', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-extension-concurrent-'));
roots.push(root);
const host = new PiManagedExtensionHost();
hosts.push(host);
const registrations = await Promise.all(Array.from({ length: 8 }, async (_, index) => (
await host.registerWorker({
conversationId: `conversation-${index + 1}`,
generation: 1,
projectId: `project-${index + 1}`,
extensionsDir: root,
})
)));
expect(new Set(registrations.map(({ extensionPath }) => extensionPath)).size).toBe(1);
expect(host.getDiagnostics().registrations).toEqual({ parent: 8, child: 0 });
await Promise.all(registrations.map(({ dispose }) => dispose()));
});
it('finishes a queued HTTP request while closing a holder and waiter', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-extension-close-'));
roots.push(root);