Keepalive PING after graceful GOAWAY disconnects draining RPCs
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- node.js, typescript
- Área
- backend-api-design, networking
Línea de trabajo
Comienza en el manejo de goaway del transporte y sigue canSendPing(), maybeSendPing(), el tiempo de espera de keepalive y el callback de finalización del PING en curso. Ejecuta la reproducción escalada con un keepalive de 100 ms y un retraso de respuesta de 500 ms; se considera terminado cuando un GOAWAY correcto detiene el manejo futuro de fallos de keepalive mientras el RPC aceptado devuelve su respuesta, sin ocultar el cierre del socket ni las desconexiones por error.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What version of gRPC and what language are you using?
@grpc/grpc-js 1.14.4 on Node.js 24.15.0. The relevant path is also unchanged on the current master branch.
What operating system are you using?
Linux.
What did you do?
Send a graceful HTTP/2 GOAWAY while a unary RPC is still running, then allow the RPC to finish after the client's keepalive interval.
This is closely related to #2624, but the current failure does not depend on an immediate server shutdown. A graceful GOAWAY by itself leaves the keepalive timer running. The next PING fails, maybeSendPing() calls handleDisconnect(), and grpc-js terminates the accepted in-flight RPC.
goaway-server.js:
const http2 = require('node:http2');
function frameMessage(payload) {
const frame = Buffer.allocUnsafe(5 + payload.length);
frame.writeUInt8(0, 0);
frame.writeUInt32BE(payload.length, 1);
payload.copy(frame, 5);
return frame;
}
const server = http2.createServer();
server.on('stream', stream => {
stream.respond(
{ ':status': 200, 'content-type': 'application/grpc' },
{ waitForTrailers: true }
);
stream.on('wantTrailers', () => {
stream.sendTrailers({ 'grpc-status': '0' });
});
setTimeout(() => {
stream.session.goaway(http2.constants.NGHTTP2_NO_ERROR, stream.id);
}, 10);
setTimeout(() => {
stream.end(frameMessage(Buffer.from('response')));
}, 20_000);
});
server.listen(50051, '127.0.0.1');
client.js:
const grpc = require('@grpc/grpc-js');
const client = new grpc.Client(
'127.0.0.1:50051',
grpc.credentials.createInsecure(),
{
'grpc.keepalive_time_ms': 15_000,
'grpc.keepalive_timeout_ms': 30_000,
'grpc.keepalive_permit_without_calls': 1
}
);
const startedAt = Date.now();
client.makeUnaryRequest(
'/repro.Service/Slow',
value => value,
value => value,
Buffer.from('request'),
{ deadline: Date.now() + 120_000 },
(error, response) => {
console.log({
elapsedMs: Date.now() - startedAt,
code: error?.code,
details: error?.details,
response: response?.toString()
});
client.close();
}
);
Run node goaway-server.js, then node client.js.
The same reproduction can be sped up deterministically by using a 100 ms keepalive and a 500 ms response delay.
What did you expect to see?
The accepted RPC finishes normally after the graceful GOAWAY and returns response at about 20 seconds. The transport is already draining and will not accept a new call, so it should not send more keepalive PINGs.
What did you see instead?
Stock 1.14.4 fails at the keepalive boundary (15,022 ms in the original reproduction) with status 14 / Connection dropped. In the scaled reproduction, stock 1.14.4 fails at about 114 ms; a transport that stops keepalive on GOAWAY returns the response at about 524 ms.
There is a second race when a PING is already in flight as GOAWAY arrives: a later PING cancellation callback can still call handleDisconnect() unless the callback also recognizes the draining state.
Suggested fix
When the session emits goaway:
- Mark the transport as draining.
- Clear the keepalive timeout.
- Make
canSendPing()/maybeSendPing()reject future PINGs. - Ignore completion of a PING that was already in flight once the transport is draining.
The existing socket close and error handlers still report genuine disconnects, and RPC deadlines continue to bound hung calls. This only stops probing a connection whose peer explicitly announced graceful draining.
- Lenguaje dominante
- TypeScript
- Estrellas
- 4.8k
- Forks
- 716
- Merge medio
- 2 d 3 h
- PR fusionados (30 d)
- 10
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de grpc/grpc-node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
package: @grpc/grpc-js
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
grpc/grpc-node#2993 · 3 comentarios · 4 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
grpc/grpc-node#3091 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
feature request
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
grpc/grpc-node#3077 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Upgrade to protobufjs version 8Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
grpc/grpc-node#3062 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de grpc/grpc-node
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
StabilityNexus/Fate-EVM-Frontend#153 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
code-yeongyu/oh-my-openagent#9039 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Tencent/teamai-cli#862 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue hacktoberfest redis
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
libredb/libredb-studio#1164 ·
Los mantenedores suelen responder en 1 día
-
flake
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
coder/xum#4920 · 2 comentarios ·
Los mantenedores suelen responder en 1 día