Server crashing on setMulticastInterface throwing EADDRNOTAVAIL
Menlog-DD opened this issue · 1 comments
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
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