Skip to content

Handle error replies and harden ESL response parsing#8

Merged
henrikbjorn merged 3 commits intomasterfrom
error-handling-and-response-parsing
Mar 18, 2026
Merged

Handle error replies and harden ESL response parsing#8
henrikbjorn merged 3 commits intomasterfrom
error-handling-and-response-parsing

Conversation

@henrikbjorn
Copy link
Copy Markdown
Member

Summary

  • Add Response#error? predicate and ResponseError exception for -ERR replies
  • send_message raises on error replies so callers don't silently swallow failures (fixes application hanging forever on -ERR)
  • run_session rescues unhandled errors and logs them — session ends cleanly
  • URL-decode all content values, not just events (connect replies contain encoded channel variables too)
  • Sanitize header key names to valid Ruby symbol chars

disconnect called close on the stream from a child fiber, which got
interrupted by session_task.stop in the Server ensure block before the
FD close completed — no TCP FIN was ever sent.

Use close_write (shutdown SHUT_WR) instead, which is an atomic kernel
syscall that sends the FIN immediately. The read_loop then sees EOF
and exits naturally, letting the Server ensure close the stream from
the owning fiber. This matches the pattern used by protocol-http1.

Also passes options through Server to listener constructors and adds
integration tests using a fake FreeSWITCH over real TCP sockets.
- Add Response#error? predicate for -ERR replies
- Raise ResponseError in send_message so callers get error handling
- Rescue unhandled errors in run_session to log and end cleanly
- URL-decode all content values, not just events (connect replies too)
- Sanitize header names to valid symbol chars (gsub non-alphanumeric)
- Suppress Ruby experimental IO::Buffer warning in tests
@henrikbjorn henrikbjorn self-assigned this Mar 17, 2026
@henrikbjorn henrikbjorn requested review from c960657 and mkyed March 18, 2026 09:01
@henrikbjorn henrikbjorn marked this pull request as ready for review March 18, 2026 09:01
@henrikbjorn henrikbjorn merged commit 6bd41c7 into master Mar 18, 2026
3 checks passed
@henrikbjorn henrikbjorn deleted the error-handling-and-response-parsing branch March 18, 2026 10:51
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.

2 participants