help
help copied to clipboard
Does data event of net/tls/http/https/http2/... promise the buffer chunk byteOffset always be 0 (never from pool)?
Details
If not, user should always use chunk.byteOffset instead of 0, and copy it for long time chunk to avoid pool leak (the original ref will prevent the other part of chunk.buffer to release).
Node.js version
all
Example code
socket.on('data', chunk => {
if ( chunk.byteOffset===0 ) { return; }
use(
new Uint8Array(
chunk.buffer,
chunk.byteOffset,// Can this simplify to 0 safely?
1,
)
);
});
Operating system
all
Scope
runtime
Module and version
net tls http https http2 ...
@bnoordhuis Would you help me? I'm a contributor of high-performance web server, I need to confirm this cautiously. And thank you for the relational help in issue #2584 .