Skip to content

@fastify/compress is using an unmaintained package (peek-stream), causing random issues #355

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

Open
2 tasks done
debianw opened this issue Apr 10, 2025 · 1 comment
Open
2 tasks done

Comments

@debianw
Copy link

debianw commented Apr 10, 2025

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

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 [email protected], 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

@mcollina
Copy link
Member

I'm aware. This module needs some rewriting that removes all that detection logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants