fix: restore live streaming in VS Code

Forward SSE chunks without reserializing events
Prevent generic proxy from buffering SSE endpoints
Add regression tests for VS Code stream proxy
This commit is contained in:
Bohdan Triapitsyn
2026-05-26 11:42:20 +03:00
parent c61f16e0dd
commit db2464d94d
4 changed files with 241 additions and 102 deletions
@@ -0,0 +1,32 @@
import { describe, expect, it, mock } from 'bun:test';
const { handleProxyBridgeMessage } = await import('./bridge-proxy-runtime');
const createDeps = () => ({
tryHandleLocalFsProxy: mock(() => Promise.resolve(null)),
buildUnavailableApiResponse: mock(() => ({ status: 503, headers: {}, bodyText: '' })),
sanitizeForwardHeaders: mock((headers) => headers || {}),
collectHeaders: mock(() => ({})),
base64EncodeUtf8: mock((text) => Buffer.from(text, 'utf8').toString('base64')),
});
describe('bridge proxy runtime', () => {
it('does not buffer SSE endpoints through the generic API proxy', async () => {
const deps = createDeps();
const response = await handleProxyBridgeMessage(
{ id: '1', type: 'api:proxy', payload: { method: 'GET', path: '/global/event?lastEventId=evt-1' } },
undefined,
deps,
);
expect(response?.success).toBe(true);
expect(response?.data).toMatchObject({
status: 400,
headers: { 'content-type': 'application/json' },
bodyText: JSON.stringify({ error: 'SSE requests must use api:sse:start' }),
});
expect(deps.tryHandleLocalFsProxy).not.toHaveBeenCalled();
expect(deps.buildUnavailableApiResponse).not.toHaveBeenCalled();
});
});