Skip to content

webrtc-sys: don't panic when C++ hands us a malformed RtcError string#1098

Open
c-tonneslan wants to merge 1 commit into
livekit:mainfrom
c-tonneslan:fix/rtc-error-no-panic
Open

webrtc-sys: don't panic when C++ hands us a malformed RtcError string#1098
c-tonneslan wants to merge 1 commit into
livekit:mainfrom
c-tonneslan:fix/rtc-error-no-panic

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #944.

The unsafe RtcError::from(&str) wrapper was .expect("malformed serialized RtcError") on the inner parse() Option, which panicked the caller's task whenever C++ handed across a string that didn't match the fixed-width hex header. Per #944 that happens on participant disconnect / call end (empty what()).

Fall back to a generic RtcErrorType::None and put the raw input in message so the error still surfaces something useful instead of taking down the task.

Added a quick test covering the empty-string and non-hex cases that used to panic.

The unsafe `RtcError::from(&str)` wrapper called `.expect("malformed
serialized RtcError")` on the `parse()` result. C++ can hand us a
string that doesn't match the fixed-width hex header — empty `what()`
on participant disconnect is the case in livekit#944 — and that panic took
out the caller's task.

Fall back to a generic `RtcErrorType::None` and stash the raw string
in `message` so the error still surfaces something useful.

Closes livekit#944.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
@c-tonneslan c-tonneslan requested a review from cloudwebrtc as a code owner May 17, 2026 00:19
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 this pull request may close these issues.

Panic in webrtc-sys rtc_error.rs (ParseIntError) on participant disconnect / call end

1 participant