rwaldron / johnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.
http://johnny-five.io
Other
13.3k stars 1.77k forks source link

i got this error message and my app crash #1435

Closed mohammedgqudah closed 6 years ago

mohammedgqudah commented 6 years ago

i have a very simple nwjs app that launch a script on start, this is my code:

var five = require('johnny-five');
var board = new five.Board();

board.on('ready', function() {
  var led = new five.Led(12);
  led.blink(500);
});

when i start the app, some arduino built-in leds blink then in the console i get this error:

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
    at Board.emit (events.js:140:19)
    at Board.log (/home/mohammed/node_modules/johnny-five/lib/board.js:630:8)
    at Board.(anonymous function) [as error] (/home/mohammed/node_modules/johnny-five/lib/board.js:641:14)
    at Board.<anonymous> (/home/mohammed/node_modules/johnny-five/lib/board.js:385:14)
    at ontimeout (timers.js:466:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Error: async hook stack has become corrupted (actual: 9, expected: 10)
 1: node::Environment::AsyncHooks::pop_async_id(double) [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnode.so]
 2: node::InternalCallbackScope::Close() [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnode.so]
 3: node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnode.so]
 4: 0x7fcfebbdf2e1 [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnode.so]
 5: 0x7fcfebff2056 [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnode.so]
 6: uv_run [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnode.so]
 7: 0x7fcfffd23cd3 [/home/mohammed/Desktop/node-webkit-projects/app/node_modules/nw/nwjs/lib/libnw.so]

i am using arduino mega 2560, and i uploaded a stranded firmata

Edit

i added this code to my script:

board.on('error', function(err) {
  alert(err)
});

and the app stop crashing, but no blinking :( the error is Error: A timeout occurred while connecting to the Board. i also tried to print the ports using the module serialport but i get this error:

Error: The module '/home/mohammed/node_modules/serialport/build/Release/serialport.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 59. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (module.js:732:18)
    at Module.load (module.js:598:32)
    at tryModuleLoad (module.js:538:12)
    at Function.Module._load (module.js:530:3)
    at Module.require (module.js:629:17)
    at require (internal/module.js:11:18)
    at bindings (/home/mohammed/node_modules/bindings/bindings.js:81:44)
    at Object.<anonymous> (/home/mohammed/node_modules/serialport/lib/bindings/linux.js:2:36)
    at Module._compile (module.js:685:30)
    at Object.Module._extensions..js (module.js:702:10)
mohammedgqudah commented 6 years ago

i solved the problem using a module called nwjs-j5-fix it is used to let you use j5 in nwjs

the code at the first line

nw.require("nwjs-j5-fix").fix();

dtex commented 6 years ago

Awesome! Thanks for following up and letting us know.