Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #900 +/- ##
==========================================
+ Coverage 91.69% 91.70% +0.01%
==========================================
Files 45 45
Lines 5479 5498 +19
==========================================
+ Hits 5024 5042 +18
- Misses 455 456 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e2a5c24 to
00c255f
Compare
00c255f to
0072963
Compare
| var localAddrsForUnspecified []net.Addr | ||
| if udpAddr, ok := params.UDPConn.LocalAddr().(*net.UDPAddr); !ok { //nolint:nestif | ||
| //nolint:nestif | ||
| if params.UDPConn == nil { |
There was a problem hiding this comment.
This seems an odd way of going around UDPConn being nil. You end up creating a broken mux. Could you share more context on what's causing UDPConn to be nil in the first place? This seems like it should be handled on the caller
There was a problem hiding this comment.
This is just because we can't introduce err to the constructor without breaking the API, user/dev errors shouldn't cause a panic, I think @FrantaBOT 's workaround is okay, idk.
There was a problem hiding this comment.
Could you share more context on what's causing UDPConn to be nil in the first place?
I want to prevent panic crash from improper use by any developer.
You end up creating a broken mux
Mux returning error is better outcome then panicking.
0072963 to
672963f
Compare
JoTurk
left a comment
There was a problem hiding this comment.
What if we make a new mux constructor with options patterns, and with errors, and deprecate this one?
|
Yeah I like constructor with options patterns much better, this to me seems like we are hiding a problem and moving along with a semi-broken system? I don't know enough about the expected behavior from the system though |
|
Closing since we can't fix it without breaking Mux API Another PITA is that this has pion/webrtc use. Should have abstracted it away :/ |
|
@FrantaBOT @Sean-Der since we're doing v5 we can reopen this I think, muxes should be able to return errors, this also can be used to return an error for the IPv6 DAD issues i talked about in discord. https://discord.com/channels/1352636971591274548/1359189787768258671/1551698660897726485 @FrantaBOT mind if you change this PR to make all the muxes return errors? |
672963f to
9dffa80
Compare
11841b4 to
9761eae
Compare
| // ErrNoTCPMux indicates that no TCPMux was provided to NewMultiTCPMuxDefault. | ||
| ErrNoTCPMux = errors.New("at least one TCPMux is required") | ||
|
|
||
| // ErrNilTCPMux indicates that a nil TCPMux was provided to NewMultiTCPMuxDefault. | ||
| ErrNilTCPMux = errors.New("TCPMux must not be nil") | ||
|
|
||
| // ErrNoUDPMux indicates that no UDPMux was provided to NewMultiUDPMuxDefault. | ||
| ErrNoUDPMux = errors.New("at least one UDPMux is required") | ||
|
|
||
| // ErrNilUDPMux indicates that a nil UDPMux was provided to NewMultiUDPMuxDefault. | ||
| ErrNilUDPMux = errors.New("UDPMux must not be nil") | ||
|
|
||
| // ErrNilTCPMuxParamsListener is returned when TCPMuxParams.Listener is nil. | ||
| ErrNilTCPMuxParamsListener = errors.New("TCPMuxParams.Listener must not be nil") | ||
|
|
||
| // ErrNilUDPMuxParamsUDPConn is returned when UDPMuxParams.UDPConn is nil. | ||
| ErrNilUDPMuxParamsUDPConn = errors.New("UDPMuxParams.UDPConn must not be nil") | ||
|
|
||
| // ErrNilUniversalUDPMuxParamsUDPConn is returned when UniversalUDPMuxParams.UDPConn is nil. | ||
| ErrNilUniversalUDPMuxParamsUDPConn = errors.New("UniversalUDPMuxParams.UDPConn must not be nil") |
9761eae to
4f1a484
Compare
4f1a484 to
f621e5f
Compare
Description
Fixes a edge case where attempting to call the NewUDPMuxDefault function with UDPConn being nil it would cause a panic.
Unfortunately, this function does not return an error and never returns nil, so there is no clearway to prevent this.