leolabs / ableton-js

Control Ableton Live with Node.js
MIT License
368 stars 46 forks source link

Random Unhandled error events #87

Closed eliaskg closed 1 year ago

eliaskg commented 1 year ago

Can't reliably reproduce it. Seems like it can happen on opening a new project but it also happened while working in a project. I have no ableton.on listeners in my script.

AbletonJS: 3.1.4

Node.js: v18.12.0

Ableton Live: 11.2.10

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Message could not be assigned to any request: {"event": "result", "data": true, "uuid": "9e2fd0f9-9bec-4c88-a128-f82b093df901"}')
    at new NodeError (node:internal/errors:393:5)
    at Ableton.emit (node:events:502:17)
    at Ableton.handleUncompressedMessage (/Users/user/Documents/Code/Scripts/ableton-js/node_modules/ableton-js/index.js:420:18)
    at Ableton.handleIncoming (/Users/user/Documents/Code/Scripts/ableton-js/node_modules/ableton-js/index.js:376:22)
    at Socket.emit (node:events:513:28)
    at UDP.onMessage [as onmessage] (node:dgram:930:8)
Emitted 'error' event on Ableton instance at:
    at Ableton.handleIncoming (/Users/user/Documents/Code/Scripts/ableton-js/node_modules/ableton-js/index.js:383:18)
    at Socket.emit (node:events:513:28)
    at UDP.onMessage [as onmessage] (node:dgram:930:8) {
  code: 'ERR_UNHANDLED_ERROR',
  context: 'Message could not be assigned to any request: {"event": "result", "data": true, "uuid": "9e2fd0f9-9bec-4c88-a128-f82b093df901"}'
}
eliaskg commented 1 year ago

Update: It is definitely happening on every Export of the project.

eliaskg commented 1 year ago

Update 2: If I implement an error handler, the error gets displayed but the script doesn't crash 🤗:

ableton.on("error", (e) => console.error("Error:", e));

leolabs commented 1 year ago

Thanks for raising this issue! These errors usually occur when the script is restarted but Live is still emitting events for listeners that the new instance of the script doesn't know about.

It shouldn't crash the script though. I've just pushed a new version that removes this error event.

eliaskg commented 1 year ago

@leolabs Awesome, thank you!