The reconnect test is flaky… +
→ Explored: 1 search, 1 read
The client closes on the first onerror and never reconnects. I'll retry instead.
┃
┃ ← Edit src/events.ts
┃
┃ 1 export function connect(url: string, onEvent: (e: Event) => void) {
┃ 2 const source = new EventSource(url);
┃ 3 source.onmessage = (m) => onEvent(JSON.parse(m.data));
┃ 4 - source.onerror = () => source.close();
┃ 4 + source.onerror = () => {
┃ 5 + source.close();
┃ 6 + setTimeout(() => connect(url, onEvent), 250);
┃ 7 + };
┃ 8 return () => source.close();
┃ 9 }
┃
┃
┃ $ bun test test/events.test.ts
┃
┃ 3 pass, 0 fail
┃
Fixed. connect() now reconnects after an error. All 3 tests pass, including the flaky one.
Build · Claude Opus 5.5 · 2.5s
┃
┃
┃
┃ Build · Claude Opus 5.5 Anthropic
╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
~/code/textjs:main 12.7K (3%) · $0.02 ctrl+p commands