Skip to content
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

undefined is not a constructor (evaluating 'new zlib.BrotliDecompress') #5701

Closed
gungun974 opened this issue Sep 18, 2023 · 1 comment
Closed
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@gungun974
Copy link

What version of Bun is running?

1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49

What platform is your computer?

Linux 6.4.15-200.fc38.x86_64 x86_64 unknown (Fedora 38)

What steps can reproduce the bug?

Create a file like test.js

Write this :

const zlib = require("zlib");

console.log(new zlib.BrotliDecompress());

What is the expected behavior?

The expected behavior with Node v18.16.0 is that :

<ref *1> BrotliDecompress {
  _writeState: Uint32Array(2) [ 0, 0 ],
  _readableState: ReadableState {
    objectMode: false,
    highWaterMark: 16384,
    buffer: BufferList { head: null, tail: null, length: 0 },
    length: 0,
    pipes: [],
    flowing: null,
    ended: false,
    endEmitted: false,
    reading: false,
    constructed: true,
    sync: false,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    destroyed: false,
    errored: null,
    closed: false,
    closeEmitted: false,
    defaultEncoding: 'utf8',
    awaitDrainWriters: null,
    multiAwaitDrain: false,
    readingMore: false,
    dataEmitted: false,
    decoder: null,
    encoding: null,
    [Symbol(kPaused)]: null
  },
  _events: [Object: null prototype] { prefinish: [Function: prefinish] },
  _eventsCount: 1,
  _maxListeners: undefined,
  _writableState: WritableState {
    objectMode: false,
    highWaterMark: 16384,
    finalCalled: false,
    needDrain: false,
    ending: false,
    ended: false,
    finished: false,
    destroyed: false,
    decodeStrings: true,
    defaultEncoding: 'utf8',
    length: 0,
    writing: false,
    corked: 0,
    sync: true,
    bufferProcessing: false,
    onwrite: [Function: bound onwrite],
    writecb: null,
    writelen: 0,
    afterWriteTickInfo: null,
    buffered: [],
    bufferedIndex: 0,
    allBuffers: true,
    allNoop: true,
    pendingcb: 0,
    constructed: true,
    prefinished: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    errored: null,
    closed: false,
    closeEmitted: false,
    [Symbol(kOnFinished)]: []
  },
  allowHalfOpen: true,
  bytesWritten: 0,
  _handle: BrotliDecoder {
    onerror: [Function: zlibOnError],
    [Symbol(owner_symbol)]: [Circular *1]
  },
  _outBuffer: <Buffer 20 74 df 49 b4 7f 00 00 20 74 df 49 b4 7f 00 00 00 b9 3b 48 b4 7f 00 00 00 b9 3b 48 b4 7f 00 00 88 87 a5 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 16334 more bytes>,
  _outOffset: 0,
  _chunkSize: 16384,
  _defaultFlushFlag: 0,
  _finishFlushFlag: 2,
  _defaultFullFlushFlag: 1,
  _info: undefined,
  _maxOutputLength: 4294967296,
  [Symbol(kCapture)]: false,
  [Symbol(kCallback)]: null,
  [Symbol(kError)]: null
}

What do you see instead?

The unexpected behavior with bun v1.0.2 is that :

1 | const zlib = require("zlib");
2 | 
3 | console.log(new zlib.BrotliDecompress());
               ^
TypeError: undefined is not a constructor (evaluating 'new zlib.BrotliDecompress')
      at /home/gungun974/test.js:3:12
      at globalThis (/home/gungun974/test.js:3:39)

Additional information

I was trying to install Sharp with Bun in the Bun official Dockerfile and I see post install was missing.

So my reflex is just to run the install sharp binary script manually and is here I found that Bun didn't support zlib.BrotliDecompress() like node does.

personally I will find an other way for my dockerfile to install sharp binary but but I still had to report this bug.

@gungun974 gungun974 added the bug Something isn't working label Sep 18, 2023
@Electroid Electroid added the node.js Compatibility with Node.js APIs label Sep 18, 2023
@nektro
Copy link
Member

nektro commented May 17, 2024

Added in #10722 and released in Bun 1.1.8 https://bun.sh/blog/bun-v1.1.8#new-brotli-support-for-node-zlib

@nektro nektro closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

3 participants