Open wy193777 opened 4 months ago
That is not really a SSE, as it needs to have Content-Type: text/event-stream
.
Anyway, you should probably not use raw.res
, but rather return a Passthrough
stream that you can keep and later write the event data to. The response won’t end until the stream is closed.
Also, a Cache-Control: no-cache
header is probably appropriate.
Contributor
what's the difference between explicitly using res.end() compare to return a PassThrough?
I just went through the code of susie, it seems pretty close to what kanongil has in mind. It's pretty old but I think it should be mostly functional even on today's hapi, you can always fork it if you find bugs.
So is there a way to do "text/event-stream" in hapi?
@wy193777 @8th-block Check this out: https://matthewwid.github.io/better-sse/reference/recipes/#hapi
I haven't tried it, but I ran into it and asked the maintainer to add a Hapi example and he did. Perhaps it can fit your needs?
Module version
21.3.10
What documentation problem did you notice?
There is no hapijs SSE example. I recently figured it out but don't know where to put it. So I have it here: