{"action":"opened","issue":{"url":"https://api.github.com/repos/voodootikigod/node-serialport/issues/660","labels_url":"https://api.github.com/repos/voodootikigod/node-serialport/issues/660/labels{/name}","comments_url":"https://api.github.com/repos/voodootikigod/node-serialport/issues/660/comments","events_url":"https://api.github.com/repos/voodootikigod/node-serialport/issues/660/events","html_url":"https://github.com/voodootikigod/node-serialport/issues/660","id":128341594,"number":660,"title":"Abort trap: 6","user":{"login":"claudio-destro","id":11568024,"avatar_url":"https://avatars.githubusercontent.com/u/11568024?v=3","gravatar_id":"","url":"https://api.github.com/users/claudio-destro","html_url":"https://github.com/claudio-destro","followers_url":"https://api.github.com/users/claudio-destro/followers","following_url":"https://api.github.com/users/claudio-destro/following{/other_user}","gists_url":"https://api.github.com/users/claudio-destro/gists{/gist_id}","starred_url":"https://api.github.com/users/claudio-destro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudio-destro/subscriptions","organizations_url":"https://api.github.com/users/claudio-destro/orgs","repos_url":"https://api.github.com/users/claudio-destro/repos","events_url":"https://api.github.com/users/claudio-destro/events{/privacy}","received_events_url":"https://api.github.com/users/claudio-destro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-23T17:36:11Z","updated_at":"2016-01-23T17:36:11Z","closed_at":null,"body":"Hi guys\r\n\r\nChatted with @reconbot about the following error I got in my code:\r\n\r\nAssertion failed: (loop->watchers[w->fd] == w), function uv__io_stop, file ../deps/uv/src/unix/core.c, line 864.\r\nAbort trap: 6\r\n\r\nit seems to be random... I got it in my library [flashmagic.js](https://github.com/claudio-destro/flashmagic.js) branch develop.\r\n\r\nplease run cli.ts with subcommand \"ping\" but I think you will need an NXP LPC hardware...\r\n\r\n```bash\r\n# ./bin/flashmagic.js -P <your_port> ping\r\n```\r\n\r\nI get the error after attempting to close and reopen a given serial port with different baud rate (see last lines in src/Handshake.ts): 9600 -> 115200.\r\n\r\n---\r\n\r\nAttempting to reproduce the issue I wrote the following code in plain javascript: **it fails fast** sometimes with [Error: Serialport not open.] (uncomment on('data')), sometimes with [Error: Cannot open /dev/tty.usbserial-FTBTBAAW].\r\n\r\nIt seems like the close/open functions do not work as expected.\r\n\r\n```javascript\r\nvar com = require('serialport');\r\n\r\nvar path = process.argv[2]\r\n\r\nvar serialport = openCom(path, 9600);\r\nvar count = 1;\r\n\r\n(function loop() {\r\n  // serialport.on('data', function(data) {\r\n  //   console.log(data);\r\n  // });\r\n  serialport.open(function(error) {\r\n    if (error) { console.error(error); throw error;}\r\n    serialport.write('?', function(error) {\r\n      if (error) { console.error(error); throw error;}\r\n      serialport.drain(function(error) {\r\n        if (error) { console.error(error); throw error;}\r\n        serialport.close(function(error) {\r\n          if (error) { console.error(error); throw error;}\r\n          console.log('closed ' + count++);\r\n          serialport = openCom(path, 115200);\r\n          process.nextTick(loop);\r\n        }); // close\r\n      }); // drain\r\n    }); // write\r\n  });\r\n})();\r\n\r\nfunction openCom(path, baud) {\r\n  return new com.SerialPort(path, {\r\n      baudRate: baud,\r\n      stopBits: 1,\r\n      parity: 'none',\r\n      parser: com.parsers.readline('\\r\\n')\r\n    }, false); // open later\r\n}\r\n\r\n/*\r\n$ uname -a\r\nDarwin iMac-di-Claudio.lan 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64\r\n$ node -v\r\nv5.4.0\r\n*/\r\n```"}}