Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

serverSideEmit(..., callback) does not deliver events until heartbeat is triggered

Abierto
#16 1 comentario 0 reacciones 0 asignados Ver en GitHub

@Harjot2022 ya está trabajando en esto.

Desde el 22/3/2026.

  • #18 de @wangxpych — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
postgresql, typescript

Línea de trabajo

Start with the Postgres adapter's serverSideEmit(..., callback) and heartbeat or server discovery flow, using the minimal reproduction in the issue. Compare callback-based emits with emits without callbacks and verify that all connected servers receive the event and return acknowledgements before any dummy emit is sent.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Environment

  • @socket.io/postgres-adapter: 0.4.0
  • socket.io: 4.8.x
  • pg: 8.16.x
  • Node.js: 22
  • PostgreSQL: 14.x

Problem description

When using serverSideEmit(..., callback), the callback is invoked with:

(err, responses) => {
  console.log(err);       // null
  console.log(responses); // [] ← empty
}

The event is never delivered to any other server, and the handler (io.on(...)) is never triggered on them.

However, if each individual server sends at least one serverSideEmit() (even a dummy one), things start working — the events are delivered and acknowledged as expected.

Note: If serverSideEmit() is used without a callback, the event is delivered to other servers even before they have sent any emits themselves. The issue only affects the ACK-based communication (serverSideEmit(..., callback)).


Root cause

The Postgres adapter does not deliver serverSideEmit(..., callback) events to other servers unless those servers have already started sending their own heartbeats.

Until a server sends a serverSideEmit():

  • It is connected and listening on the correct LISTEN channel
  • It can receive broadcast events without callback
  • But it will not be discoverable by other servers for ACK-based communication (serverSideEmit(..., callback))

As a result:

  • The initiating server sends a request and waits for ACKs
  • But other servers ignore the request because they don't recognize the source as active
  • The callback returns with responses = []

Minimal reproduction

// on all servers:
io.on("test-ack", (data, callback) => {
  console.log("received:", data);
  callback("ack from " + process.pid);
});

// on emitter server:
setTimeout(() => {
  io.serverSideEmit("test-ack", "hello", (err, responses) => {
    console.log("err:", err);           // null
    console.log("responses:", responses); // [] if heartbeat not yet started on other servers
  });
}, 1000);

Workaround

Ensure that every server sends a dummy serverSideEmit() after startup to trigger the heartbeat:

io.serverSideEmit("__init__", "poke");

This ensures each server becomes discoverable by others and can participate in ACK-based messaging.

Lenguaje dominante
TypeScript
Estrellas
27
Forks
9
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de socketio/socket.io-postgres-adapter

Todos los issues de socketio/socket.io-postgres-adapter

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.