From 3ad4f0b8e9d979b988b658c0a5b83db4c4cf8216 Mon Sep 17 00:00:00 2001 From: Guilherme Dellagustin Date: Sun, 26 Mar 2023 22:41:18 +0200 Subject: [PATCH] Fix #244 Disable buffer for comments Comments for an episode are sent back to the front end using chunked Transfer Enconding, but that that is not supported on HTTP/2 which is used by the reverse proxy (nginx). At the moment nginx buffers the chunks before sending them to the browser, which breaks the way the chunks are processed. With this commit, we use the header X-Accel-Buffering to disable this buffering, which worked in local testing. We should still add a more clear chunk delimiter so that any other buffering or unknown edge case will not break the comments function (increase robustness). Co-authored-by: ericpp --- server/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/index.js b/server/index.js index fd595fde..0df9b34a 100644 --- a/server/index.js +++ b/server/index.js @@ -137,6 +137,10 @@ app.use('/api/comments/byepisodeid', async (req, res) => { const cache = new InMemoryCache(); const fetcher = makeRateLimitedFetcher(fetch); + // Disable buffering in the nginx server so that the delivery of + // chunks are not delayed + res.setHeader('X-Accel-Buffering', 'no'); + const sentCommenters = {}; const threadcap = await makeThreadcap(socialInteract[0].uri, { userAgent, cache, fetcher });