79614260

Date: 2025-05-09 13:49:07
Score: 2.5
Natty:
Report link

In your POST-triggered push version, you are not keeping the stream open in the GET method for the '/sse' route. As a result, the stream gets closed, and your frontend is no longer able to read from it.

The only required modification is adding a while (true) loop to keep the stream open:

app.get('/sse', async (c) => {
  return streamSSE(c, async (stream) => {
    activeStreams.add(stream);

    stream.onAbort(() => {
      activeStreams.delete(stream);
    });

    // Send initial message (optional)
    await stream.writeSSE({
      data: `Connected at ${new Date().toISOString()}`,
      event: "time-update",
      id: String(id++),
    });


    // While-True loop to keep stream open
    while (true) {
      await stream.sleep(1000); // default delay
    }
  });
});

Please let me know whether this resolves your issue!

Reasons:
  • RegEx Blacklisted phrase (2.5): Please let me know
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Alpharius397