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

node-canvas NAPI crash after multiple calls #8055

Closed
7f8ddd opened this issue Jan 9, 2024 · 6 comments
Closed

node-canvas NAPI crash after multiple calls #8055

7f8ddd opened this issue Jan 9, 2024 · 6 comments
Labels
bug Something isn't working crash An issue that could cause a crash napi Compatibility with the native layer of Node.js

Comments

@7f8ddd
Copy link
Contributor

7f8ddd commented Jan 9, 2024

What version of Bun is running?

1.0.21+88fcfa446

What platform is your computer?

Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

You will need to install the dependencies required to build it listed at https://github.com/Automattic/node-canvas .

bun i git+https://github.com/Automattic/node-canvas.git
(or use npm i --build-from-source in the directory)

import { createCanvas } from "canvas";

for (let i = 0; i < 25; i++) {
  const canvas = createCanvas(400, 400);
  const ctx = canvas.getContext("2d");
  console.log(canvas.toDataURL())
}

What is the expected behavior?

25 empty images should be printed to the console.

What do you see instead?

A few images work just fine, then:

napi: napi_define_properties
  Error::Error

uh-oh: napi: napi_define_properties
  Error::Error
bun will crash now 😭😭😭

----- bun meta -----
Bun v1.0.21 (88fcfa44) Linux x64 #1 SMP Thu Oct 5 21:02:42 UTC 2023
RunCommand: dotenv 
Elapsed: 2596ms | User: 219ms | Sys: 31ms
RSS: 83.98MB | Peak: 0.15GB | Commit: 83.98MB | Faults: 0
----- bun meta -----

0   0x55b372af678b
1   ???
2   ???
3   ???
4   ???
5   ???
6   ???
7   ??? napi_fatal_error
8   ???
9   ??? Napi::Error::Error(napi_env__*, napi_value__*)
10  ??? Napi::ObjectWrap<Context2d>::ConstructorCallbackWrapper(napi_env__*, napi_callback_info__*)

Additional information

I am almost certain it was working previously.

@7f8ddd 7f8ddd added the bug Something isn't working label Jan 9, 2024
@Electroid
Copy link
Contributor

Related to #5835

@Electroid Electroid added napi Compatibility with the native layer of Node.js crash An issue that could cause a crash labels Jan 9, 2024
@7f8ddd
Copy link
Contributor Author

7f8ddd commented Jan 9, 2024

Related to #5835

That issue was resolved, they just haven't updated the package version in a year, so you have to manually build it. It works fine unless you call it too many times.

@n1ckoates
Copy link

Is there a workaround for this issue right now? Running into this issue when multiple users run a Discord bot command that uses node-canvas. @napi-rs/canvas is incompatible with Bun also, so there isn't a working Canvas implementation afaik.

@Jarred-Sumner
Copy link
Collaborator

Is there a workaround for this issue right now? Running into this issue when multiple users run a Discord bot command that uses node-canvas. @napi-rs/canvas is incompatible with Bun also, so there isn't a working Canvas implementation afaik.

What's the issue with @napi-rs/canvas?

@n1ckoates
Copy link

n1ckoates commented Jan 19, 2024

What's the issue with @napi-rs/canvas?

I should've been more clear, it's an issue with installing it right now: #7617

edit: though now that I test it with latest Bun, @napi-rs/canvas seems to install fine.

@Jarred-Sumner
Copy link
Collaborator

No longer reproduces as of Bun v1.1.20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash napi Compatibility with the native layer of Node.js
Projects
None yet
Development

No branches or pull requests

4 participants