]> cat aescling's git repositories - mastodon.git/commitdiff
minor server-sent events fixes (#12945)
authorBen Lubar <ben.lubar@gmail.com>
Fri, 24 Jan 2020 19:51:33 +0000 (13:51 -0600)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 24 Jan 2020 19:51:33 +0000 (20:51 +0100)
* Send output on the server-sent events stream immediately so the client sees that it was successfully opened even if it doesn't have any messages.

Fix transparent SSE streaming for the public:local and hashtag:local stream types.

* Tell caches to never store server-sent events.

app/javascript/mastodon/stream.js
streaming/index.js

index fe965bcb0e90f22e81e4ce66c2520610abb49640..0cb2b228f3c29b8e33fd120d1734a4aeb26fc585 100644 (file)
@@ -92,6 +92,7 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
     return ws;
   }
 
+  stream = stream.replace(/:/g, '/');
   params.push(`access_token=${accessToken}`);
   const es = new EventSource(`${streamingAPIBaseURL}/api/v1/streaming/${stream}?${params.join('&')}`);
 
index 304e7e0465bed4e3b79a2b8e2e8e53792779d99f..0a19c74a633587b5353559d852b3787d33934355 100644 (file)
@@ -436,8 +436,11 @@ const startWorker = (workerId) => {
     const accountId = req.accountId || req.remoteAddress;
 
     res.setHeader('Content-Type', 'text/event-stream');
+    res.setHeader('Cache-Control', 'no-store');
     res.setHeader('Transfer-Encoding', 'chunked');
 
+    res.write(':)\n');
+
     const heartbeat = setInterval(() => res.write(':thump\n'), 15000);
 
     req.on('close', () => {