[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.
Sebastian Markbåge committed
Mar 10, 2023 at 19:48 UTC
774111855d25cfadd56e564a6fef20022989de74
1 file changed
+7
-1
fixtures/flight/server/global.js
+7
-1
@@ -157,7 +157,13 @@ app.all('/', async function (req, res, next) {
157
const rscResponse = await promiseForData;
158
// For other request, we pass-through the RSC payload.
159
res.set('Content-type', 'text/x-component');
160
- rscResponse.pipe(res);
160
+ rscResponse.on('data', data => {
161
+ res.write(data);
162
+ res.flush();
163
+ });
164
+ rscResponse.on('end', data => {
165
+ res.end();
166
+ });
167
} catch (e) {
168
console.error(`Failed to proxy request: ${e.stack}`);
169
res.statusCode = 500;