Skip to content

Commit 83733f8

Browse files
committed
Comment about streaming.
Just noting to future readers about why we read into a buffer for the test. If you do manage to pipe in a stream, it will likely stall unless you use a tiny image or give it a really big buffer, as the server will be waiting for the client to receive the output so it can drain the write buffer.
1 parent b48a145 commit 83733f8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/server-test.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ describe('Resizing API', function() {
2323
});
2424

2525
it('should resize an image to WebP format', async function() {
26+
/*
27+
Read the image file into a memory buffer.
28+
It would be good to use a readable stream here to demonstrate the streaming,
29+
but that would require a client that was capable of reading the response
30+
stream at the same time as sending the request body, which supertest does not support.
31+
32+
So we read the file into a buffer and send it in one go.
33+
*/
2634
const imageBuffer = await fs.readFile('./test/images/goose (lossy).png');
2735
await request(app.callback())
2836
.post('/resize/webp')

0 commit comments

Comments
 (0)