Check stream backpressure before upgrading Node
Run the same stream probe on Node 20 and 22, then check where write starts returning false before switching production traffic.
Your service runs on Node 20, and you want to switch the deployment to Node 22. A test suite can pass on both versions while a busy upload or export uses more memory under load. If you have byte streams in that path, check where they signal backpressure before you change the runtime.
Compare one write on both runtimes
Save this as stream-probe.mjs and run node stream-probe.mjs under Node 20 and again under Node 22. The writable finishes the chunk on the next turn, so the first call to write() reports its result while the chunk is still pending.
import { Writable } from 'node:stream'
const options = process.argv.includes('--pin')
? { highWaterMark: 16 * 1024 }
: {}
const sink = new Writable({
...options,
write(_chunk, _encoding, done) {
setImmediate(done)
},
})
console.log('threshold:', sink.writableHighWaterMark)
console.log('write:', sink.write(Buffer.alloc(16 * 1024)))
sink.end()With default options and one 16 KiB chunk, Node 20 prints threshold: 16384 and write: false, and Node 22 prints threshold: 65536 and write: true.
diagram
Same pending chunk, different thresholds
Node 22 raised the default threshold for streams. The probe uses a plain byte-mode Writable with no override. Read writableHighWaterMark on the actual stream in your service, since a specific stream class or option can have a different value.
A false result tells the producer to pause until drain, per the writable stream contract. The stream has already accepted that chunk, so resume with the next one. A producer that keeps writing can queue more data past the threshold.
Keep the former threshold if you need it
Run node stream-probe.mjs --pin under Node 22. The probe now prints threshold: 16384 and write: false. Use an explicit highWaterMark on the byte stream you own if you need to hold that variable steady during the runtime rollout.
Repeat a representative export or upload in staging with a slow downstream and realistic concurrency. Compare process memory and throughput with the same workload on Node 20. If a producer ignores false, fix its pause and resume handling before you tune the buffer.