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

Server crashing on setMulticastInterface throwing EADDRNOTAVAIL #77

Open
Menlog-DD opened this issue Aug 4, 2021 · 1 comment
Open

Comments

@Menlog-DD
Copy link

Hello,

I am wondering if this is the normal behavior not to catch any error that might be thrown from call to setMulticastInterface

socket.setMulticastInterface(opts.interface || defaultInterface())

As specified in dgram's documentation, a call to setMulticastInterface might throw a System Error such as EADDRNOTAVAIL or EPROTONOSUP
https://nodejs.org/api/dgram.html#dgram_call_results

For now i didn't find a way to properly catch this exception in my program other than using process.on('uncaugthException') which i find ugly

Am I missing something or is it the only way ?

Ty for your time

@Menlog-DD
Copy link
Author

From what i see the function that.update containing setMulticastInterface is called in a setInterval()

We might handle the case getting the exception thrown by
socket.setMulticastInterface(opts.interface || defaultInterface())
by placing a try/catch block

Then on error, we might check if in the options was provided a Callback function (onMulticastInterfaceError/Exception)
-> If there is no callback, release the error by throwing it again as it is currently the case (no breaking changes)
-> If there is a callback, call it with the Error as parameter and abort current update

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

No branches or pull requests

1 participant