Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling errors in unpack in Node.js #75

Closed
arnogramatke opened this issue Dec 19, 2023 · 2 comments · Fixed by #79
Closed

Handling errors in unpack in Node.js #75

arnogramatke opened this issue Dec 19, 2023 · 2 comments · Fixed by #79

Comments

@arnogramatke
Copy link

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.

@soimon
Copy link

soimon commented Apr 16, 2024

I agree: for art installations (or anything artistic or performative: that's where OSC is mostly used) this behaviour is worrysome. I would suggest the errors that are thrown now, should be emitted to the "error" event handlers: that is the behaviour I would expect (since it exists already).

osc.on('error', (err: Error) => {
	console.log(err);
});

@adzialocha
Copy link
Owner

Thank you for this report, it's indeed unfortunate that internal errors haven't been caught and reported correctly. I provided a test and fix here: #79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants