[Flight Fixture] Fix proxying with compression (#26368)

We're decompressing and then writing and recompressing in the proxy.
This causes it to stall if buffered because `.pipe()` doesn't force
flush automatically.
This commit is contained in:
Sebastian Markbåge 2023-03-10 19:48:46 -05:00 committed by GitHub
parent 69fd78fe37
commit 774111855d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -157,7 +157,13 @@ app.all('/', async function (req, res, next) {
const rscResponse = await promiseForData;
// For other request, we pass-through the RSC payload.
res.set('Content-type', 'text/x-component');
rscResponse.pipe(res);
rscResponse.on('data', data => {
res.write(data);
res.flush();
});
rscResponse.on('end', data => {
res.end();
});
} catch (e) {
console.error(`Failed to proxy request: ${e.stack}`);
res.statusCode = 500;