Prerequisites
Fastify version
4.25.2
Plugin version
6.5.0
Node.js version
22.14
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
I am encountering an issue in my Fastify-based application where the @fastify/compress plugin is causing a random TypeError related to the peek-stream package. The error trace is as follows:
TypeError: Cannot read properties of null (reading 'length')
at getStateLength (/path/to/node_modules/stream-shift/index.js:16:28)
at shift (/path/to/node_modules/stream-shift/index.js:6:99)
at Duplexify._forward (/path/to/node_modules/peek-stream/node_modules/duplexify/index.js:168:35)
at Duplexify._read (/path/to/node_modules/peek-stream/node_modules/duplexify/index.js:159:8)
at Duplexify.Readable.read (/path/to/node_modules/peek-stream/node_modules/readable-stream/lib/_stream_readable.js:443:10)
at flow (/path/to/node_modules/peek-stream/node_modules/readable-stream/lib/_stream_readable.js:813:34)
at ServerResponse.<anonymous> (/path/to/node_modules/peek-stream/node_modules/readable-stream/lib/_stream_readable.js:683:7)
at ServerResponse.emit (node:events:518:28)
at socketOnDrain (node:_http_server:785:9)
at Socket.emit (node:events:518:28)
at afterWrite (node:internal/streams/writable:705:12)
at onwrite (node:internal/streams/writable:688:7)
at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:105:10)
Upon investigating, I found that @fastify/compress still depends on peek-stream@1.1.3, which is an unmaintained package. This is problematic because peek-stream is no longer actively maintained and has known issues, which are leading to the error mentioned above.
I think this is due to the use of stream-shift
Take a look this issue: mafintosh/stream-shift#6
Link to code that reproduces the bug
mafintosh/stream-shift#6
Expected Behavior
No response
Prerequisites
Fastify version
4.25.2
Plugin version
6.5.0
Node.js version
22.14
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
I am encountering an issue in my Fastify-based application where the @fastify/compress plugin is causing a random TypeError related to the peek-stream package. The error trace is as follows:
Upon investigating, I found that @fastify/compress still depends on peek-stream@1.1.3, which is an unmaintained package. This is problematic because peek-stream is no longer actively maintained and has known issues, which are leading to the error mentioned above.
I think this is due to the use of
stream-shiftTake a look this issue: mafintosh/stream-shift#6
Link to code that reproduces the bug
mafintosh/stream-shift#6
Expected Behavior
No response