oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.31k stars 2.58k forks source link

Segmentation fault with nutjs #2685

Open LookRain opened 1 year ago

LookRain commented 1 year ago

What version of Bun is running?

0.5.9

What platform is your computer?

Darwin 22.4.0 arm64 arm

What steps can reproduce the bug?

import {mouse, straightTo} from '@nut-tree/nut-js';

const inputPos = {x: -567, y: 1414};
mouse.move(straightTo(inputPos));

bun index.js output:

[1]    18395 segmentation fault  bun index2.js

What is the expected behavior?

The code should run without error.

What do you see instead?

[1] 18395 segmentation fault bun index2.js

Additional information

demo repo: https://github.com/LookRain/bun-error-demo run bun index2.js to reproduce

index.js with robotjs also has issues, but it's a different one seemingly related to module resolution.

birkskyum commented 11 months ago

This doesn't segfault anymore, but it does give this error:

➜ bun --bun run index.ts
execa/lib/errname: unable to establish process.binding('uv') 1 | (function (bindingName){"use strict";if(bindingName==="constants")return @processBindingConstants;const issue={fs:3546,buffer:2020,natives:2254,uv:2891}[bindingName];if(issue)throw new Error(`process.binding("${bindingName}") is not implemented in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/${issue}`);@throwTypeError(`process.binding("${bindingName}") is not implemented in Bun. If that breaks something, please file an issue and include a reproducible code sample.`)})
                       ^
error: process.binding("uv") is not implemented in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/2891
birkskyum commented 10 months ago

After granting permissions, the repro still breaks with:

➜ bun index.ts
[0.04ms] ".env"
zsh: bus error  bun index.ts

and sometimes

➜ bun index.ts
[0.04ms] ".env"
zsh: segmentation fault  bun index.ts
Jarred-Sumner commented 10 months ago

robotjs uses NAN which relies on V8 C++ API that we don't currently support.

https://github.com/octalmage/robotjs/blob/master/src/robotjs.cc

nektro commented 2 months ago

the v8 comment may still apply, but did the project go private? https://npmjs.com/package/@nut-tree/nut-js doesn't load for me and bun-debug add @nut-tree/nut-js yields:

❯ bun-debug add @nut-tree/nut-js
[0.20ms] ".env.production"
bun add v1.1.10 (d3fdb173)
  🔍 @nut-tree/nut-js [2/2] 
error: package "@nut-tree/nut-js" not found registry.npmjs.org/@nut-tree%2fnut-js 404

with npm having a similar error:

❯ npm install @nut-tree/nut-js
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@nut-tree%2fnut-js - Not found
nektro commented 2 months ago

the website shows the same package name as OP https://nutjs.dev/docs/installation#installation