ReconnectingWebSocket drops messages the server sends right after the handshake
Mantenedores costumam responder em até 2 dias
@EhabY já está trabalhando nisso.
Desde 12/10/2026.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- node.js, typescript
- Domínio
- backend, networking, testing
Direção de pesquisa
Start with src/websocket/reconnectingWebSocket.ts and src/api/coderApi.ts, tracing when the socket opens and when connect() registers listeners. Add a test where the server sends a message immediately on connection, as described in the issue. Done means the first message reaches subscribers on initial connect and reconnect; run the relevant WebSocket tests.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Found in review of #1128.
Problem
ReconnectingWebSocket.connect() (src/websocket/reconnectingWebSocket.ts) attaches its message listener to the underlying socket only after await this.#socketFactory() resolves. The factory, createOneWayWebSocket in src/api/coderApi.ts, resolves through waitForOpen on the open event.
The server can send its first frame in the same chunk as the handshake. ws emits it on a process.nextTick, which runs before the awaited promise resumes connect(). So that message reaches no listener, and subscribers never see it. The stream logger attached in attachStreamLogger is registered before open, so it still logs the message; only delivery is lost.
This happens on the first connect and on every reconnect.
Impact
Any stream whose server writes right after the handshake can lose its first message. For example, watchAgentMetadata can show nothing until the agent's next metadata update. I haven't checked each stream: the workspace watch, build logs and agent logs may lose their first event or backlog the same way. The SSE fallback (SseConnection) isn't checked either.
Repro
A plain ws 8.22.0 client against a server that sends one message on connection. The client resolves a promise on open, awaits it, then adds its message listener, mirroring connect():
listener after awaited open: 20/20 dropped
listener before open: 0/20 dropped
Script
import { WebSocket, WebSocketServer } from "ws";
const server = new WebSocketServer({ port: 0 });
server.on("connection", (socket) => socket.send("initial"));
await new Promise((resolve) => server.once("listening", resolve));
const url = `ws://127.0.0.1:${server.address().port}`;
async function attempt(listenFirst) {
const socket = new WebSocket(url);
let received = false;
const onMessage = () => (received = true);
if (listenFirst) socket.on("message", onMessage);
await new Promise((resolve, reject) => {
socket.once("open", resolve);
socket.once("error", reject);
});
if (!listenFirst) socket.on("message", onMessage);
await new Promise((resolve) => setTimeout(resolve, 100));
socket.terminate();
return received;
}
for (const listenFirst of [false, true]) {
let dropped = 0;
for (let i = 0; i < 20; i++) if (!(await attempt(listenFirst))) dropped++;
console.log(`${listenFirst ? "before" : "after awaited"} open: ${dropped}/20 dropped`);
}
server.close();
Fix
Attach the message (and other) listeners before the socket opens. For example, have the factory return the socket unopened and let connect() wait for open after registering its listeners, or have OneWayWebSocket buffer messages until a listener is attached. Add a test where the server sends a message as soon as the connection opens.
- Linguagem predominante
- TypeScript
- Estrelas
- 132
- Forks
- 48
- Merge médio
- 1d 18h
- PRs com merge (30d)
- 29
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de coder/vscode-coder
-
Split commands.ts by topicTalvez já em andamento @EhabY assumiu há 5 dias. AbertaImprovement tech-debt vs-code
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
coder/vscode-coder#1135 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 2 dias
-
Design the VS Code Workspaces panelTalvez livre de novo @chrifro assumiu há 33 dias e não há nenhum pull request aberto. Aberta
coder/vscode-coder#1113 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 2 dias
-
bug upstream
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
coder/vscode-coder#1087 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Improvement tech-debt vs-code
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
coder/vscode-coder#1066 · 2 comentários ·
Mantenedores costumam responder em até 2 dias
-
Feature vs-code
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
coder/vscode-coder#1027 · 3 comentários ·
Mantenedores costumam responder em até 2 dias
Todas as issues de coder/vscode-coder
Issues semelhantes
-
Object parameters lose their structure when resources is enabledTalvez já em andamento @asts-top assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
jaegertracing/jaeger-ui#4618 ·
Mantenedores costumam responder em até 1 dia
-
pending close triaging
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
anomalyco/opencode#56765 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
area:plugins enhancement platform:vscode
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
anthropics/claude-code#103166 ·
Mantenedores costumam responder em até 1 dia
-
Types: FlashListProps imports ViewabilityConfig from react-native, removed in RN 0.87+Talvez já em andamento @efegokdemir assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Shopify/flash-list#2540 ·