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

async @napi-rs/canvas crashes under load #12375

Open
7f8ddd opened this issue Jul 5, 2024 · 1 comment
Open

async @napi-rs/canvas crashes under load #12375

7f8ddd opened this issue Jul 5, 2024 · 1 comment
Labels
crash An issue that could cause a crash linux An issue that only occurs on Linux

Comments

@7f8ddd
Copy link
Contributor

7f8ddd commented Jul 5, 2024

How can we reproduce the crash?

bun i @napi-rs/canvas

import { createCanvas } from "@napi-rs/canvas";

async function generate() {
  const canvas = createCanvas(400, 200);
  const ctx = canvas.getContext("2d");

  ctx.fillStyle = "#FFFFFF";
  ctx.fillRect(0, 0, canvas.width, canvas.height);

  const encoded = await canvas.encode("webp");

  return `data:image/webp;base64,${encoded.toString("base64")}`;
}

while (true) {
  generate();
}

Relevant log output

No response

Stack Trace (bun.report)

Bun v1.1.18 (ee25618) on linux x86_64 [RunCommand]

Segmentation fault at address 0x63DDD711F

@7f8ddd 7f8ddd added the crash An issue that could cause a crash label Jul 5, 2024
@github-actions github-actions bot added the linux An issue that only occurs on Linux label Jul 5, 2024
@7f8ddd
Copy link
Contributor Author

7f8ddd commented Jul 5, 2024

This causes things like captcha generation or Discord bot image generation to randomly crash when under load.
By load, I mean around 1000 rq/s or less.

Adding a Bun.sleepSync(1) is how I temporarily resolved the problem.

It may be even less rq/s if the encode takes longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash linux An issue that only occurs on Linux
Projects
None yet
Development

No branches or pull requests

1 participant