Describe the bug
Node.js version: v22.14.0
OS version: Windows 11
Description:
When I use maxResponseSize and the response is larger than the size I've set, I receive superagent: double callback bug.
This is the case for any image URLs I tried, and also some other links like https://google.com. However there's also some links that does not cause this, for example: https://example.com
Actual behavior
superagent: double callback bug
superagent: double callback bug
Error: Maximum response size reached
at IncomingMessage.<anonymous> (D:\test\node_modules\superagent\lib\node\index.js:1034:25)
at IncomingMessage.emit (node:events:529:35)
at Readable.read (node:internal/streams/readable:582:10)
at flow (node:internal/streams/readable:1064:34)
at resume_ (node:internal/streams/readable:1045:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ETOOLARGE',
response: null
}
Expected behavior
I should only receive the maximumr esponse size reached error
Code to reproduce
const superagent = require('superagent');
superagent
.get('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg')
.maxResponseSize(1)
.then((res) => console.log(res.body))
.catch((err) => console.error(err));
Checklist
Describe the bug
Node.js version: v22.14.0
OS version: Windows 11
Description:
When I use
maxResponseSizeand the response is larger than the size I've set, I receivesuperagent: double callback bug.This is the case for any image URLs I tried, and also some other links like https://google.com. However there's also some links that does not cause this, for example: https://example.com
Actual behavior
Expected behavior
I should only receive the maximumr esponse size reached error
Code to reproduce
Checklist