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

trouble with sharp/jimp #13846

Closed
Shawak opened this issue Sep 10, 2024 · 5 comments
Closed

trouble with sharp/jimp #13846

Shawak opened this issue Sep 10, 2024 · 5 comments
Assignees
Labels
bug Something isn't working node:zlib regression

Comments

@Shawak
Copy link

Shawak commented Sep 10, 2024

What version of Bun is running?

1.1.27

What platform is your computer?

debian/alpine docker container

What steps can reproduce the bug?

Upgrade to 1.1.27 and use the jimp package, e.g.:

import Jimp from 'jimp';
import sharp from 'sharp';

  const buffer = await (async () => {
      const response = await fetch(imageLink);
      const arrayBuffer = await response.arrayBuffer();
      return await sharp(arrayBuffer).toFormat('png').toBuffer();
  })();

  const image = await Jimp.read(buffer);
  const imageBuffer = await image
      .invert()
      .greyscale()
      .getBufferAsync(Jimp.MIME_PNG);

What is the expected behavior?

No response

What do you see instead?

Date: Tue Sep 10 2024 07:03:51 GMT+0000 (Coordinated Universal Time)
106 |   }
107 | 
108 |   assert(this._handle, "zlib binding closed");
109 |   let res;
110 |   do {
111 |     res = this._handle.writeSync(
                             ^
TypeError: this._handle.writeSync is not a function. (In 'this._handle.writeSync(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset, availOutBefore)', 'this._handle.writeSync' is undefined)
      at /home/bun/app/node_modules/pngjs/lib/sync-inflate.js:111:24
      at /home/bun/app/node_modules/pngjs/lib/parser-sync.js:85:20
      at /home/bun/app/node_modules/@jimp/core/dist/utils/image-bitmap.js:157:47

Additional information

No response

@nektro
Copy link
Contributor

nektro commented Sep 25, 2024

As of #14079, now fails with

1 | (function (entry, fetcher)
    ^
SyntaxError: module '/Users/meghandenny/src/test/node_modules/jimp/dist/esm/index.js' does not have an export named 'default'. Did you mean 'Jimp'?
      at asyncFunctionResume (1:11)
      at promiseReactionJobWithoutPromiseUnwrapAsyncContext (1:11)
      at promiseReactionJob (1:11)

Bun v1.1.30-debug+6aabaa617 (macOS arm64)

@nektro
Copy link
Contributor

nektro commented Sep 25, 2024

changing first line to import { Jimp } from "jimp"; fails with

5 |   const response = await fetch(imageLink);
                                            ^
ReferenceError: Can't find variable: imageLink
      at /Users/meghandenny/src/test/index.js:5:41

@nektro nektro added the needs repro Needs an example to reproduce label Sep 25, 2024
Copy link
Contributor

Hello @Shawak. Please provide a minimal reproduction using a GitHub repository, Replit, or CodeSandbox. Issues marked with needs repro will be closed if they have no activity within 3 days.

@nektro nektro changed the title zlib crash, missing function since zlib rewrite trouble with sharp/jimp Sep 25, 2024
@tobias-theobald
Copy link

I have created a minimal reproduction on replit. This does work with node/tsx.

Note how the crash actually happens in pngjs but it's inheriting the Inflate class from zlib (a node-native module) and doing something weird with underscore-prefixed methods, a notation which should be reserved for internals. zlib should be supported by bun, that is how I understand the claim that it's not optimized though.

@nektro nektro added regression node:zlib and removed needs repro Needs an example to reproduce labels Sep 27, 2024
@nektro
Copy link
Contributor

nektro commented Sep 27, 2024

excellent, thanks. can confirm this is now fixed by the latest canary and will be available again in 1.1.30

@nektro nektro closed this as completed Sep 27, 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:zlib regression
Projects
None yet
Development

No branches or pull requests

4 participants