osc-js icon indicating copy to clipboard operation
osc-js copied to clipboard

Handling errors in unpack in Node.js

Open arnogramatke opened this issue 2 years ago • 0 comments

I am using osc-js in a Node.js environment with the DatagramPlugin.

When a malformed UDP packet arrives, where the path doesn't start with a /, osc-js throws an error with the message OSC Message found malformed or missing address string. In my case this causes the application to exit with code 1, although I think, osc-js could recover from this error by ignoring this message. (For your reference: such a malformed packet is being produced by the JUCE OSC component, when the path is just a /. JUCE removes trailing slashes and creating an invalid OSC message).

What is the recommended way to handle errors that might occur during unpacking an OSC message (or any other recoverable error)? As a workaround I am using process.on('uncaughtException', (error) => {...}) to handle this, but this gets difficult to handle, since I wouldn't want to catch other unhandled exceptions, except the ones from osc-js.

Also, I think it would make sense to catch recoverable errors in osc-js and fire the 'error' event of osc-js instead of crashing the application.

arnogramatke avatar Dec 19 '23 11:12 arnogramatke