fix: attempt to fix sse
This commit is contained in:
@@ -55,15 +55,19 @@ export class PubSubManager {
|
||||
function ping() {
|
||||
clearTimeout(heartbeatTimeout);
|
||||
heartbeatTimeout = setTimeout(() => {
|
||||
try {
|
||||
void writer.write(":)\n\n").catch(() => { });
|
||||
} catch { }
|
||||
ping();
|
||||
}, 90000); // cloudflare timeout = 100s
|
||||
}
|
||||
|
||||
const write = (payload: PubPayload) => {
|
||||
try {
|
||||
void writer
|
||||
.write(this.constructMessage(payload.data, payload.event))
|
||||
.catch(() => { });
|
||||
} catch { }
|
||||
ping();
|
||||
};
|
||||
|
||||
@@ -83,6 +87,7 @@ export class PubSubManager {
|
||||
console.log(` DSC ${topic}`);
|
||||
|
||||
sub.unsubscribe(`${this.prefix}${topic}`, handler);
|
||||
void writer.close().catch(() => { });
|
||||
clearInterval(heartbeatTimeout);
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user