-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leaking array buffers #434
Comments
Have you got a repro? You can possibly find them using heapdump. |
@ronag I remember there was a bug in Node.js 12 related to TLS sockets. What Node.js version are you running? |
14.8, HTTP Happens at multiple locations with different node versions. I see that V8 recently did something with GC of ArrayBuffers. Maybe coincidence... |
I’ll have to continue digging on Monday. Anyway, a FYI in case it affects you. |
Does that work with cluster? |
It might work given some adaptation. |
Seem to have the same problem on a totally different service which recently started to use undici |
Been trying to create a repro without success 😞 |
@ronag How does the |
`Client.request`` I think it might be broken back pressure. |
My current guess it that it has something to do with pause/resume multiple times. This seems to be growing arrayBuffer usage infinitiely: 'use strict'
const { Client } = require('..')
const { createServer } = require('http')
const { Readable } = require('stream')
const requests = 128
const server = createServer()
const limit = 1e9
server.on('request', (req, res) => {
let bytesWritten = 0
const interval = setInterval(() => {
console.log(process.memoryUsage().arrayBuffers / 1e6, bytesWritten, bytesWritten / limit)
}, 1e3)
const buf = Buffer.allocUnsafe(16384)
new Readable({
read () {
bytesWritten += buf.length
this.push(buf)
if (bytesWritten >= limit) {
clearInterval(interval)
this.push(null)
}
}
}).pipe(res)
})
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`, {
pipelining: 1
})
for (let n = 0; n < requests; ++n) {
client.request({ path: '/', method: 'GET', opaque: 'asd' }, (err, data) => {
if (err) {
console.error(err)
}
data.body
.resume()
.on('data', () => {
data.body.pause()
setTimeout(() => data.body.resume(), 1e3)
})
})
}
}) |
Could it be that |
Yep, that's the problem. |
@ronag Is it possible to pause a response using |
Return false in |
Not sure if this is a user, undici, node or V8 bug but I have case where I have lot's of ArrayBuffers allocated and never freed in our Node based proxy:
@mcollina @addaleax any hints on how to debug this?
The text was updated successfully, but these errors were encountered: