-
-
Notifications
You must be signed in to change notification settings - Fork 215
Description
Description
Sentry.LiveViewHook.on_mount/4 crashes with Bandit.TransportError: Unable to obtain peer_data when a client disconnects before the LiveView mount completes.
Root Cause
In lib/sentry/live_view_hook.ex, the get_connect_info(socket, :peer_data) call on line 82 is not wrapped in a try/rescue. When using Bandit as the web server, if the underlying WebSocket transport is already closed at the time of the call, Bandit raises Bandit.TransportError.
The existing catch block in get_safe_ip_address/1 only protects the :inet.ntoa call — it does not protect get_connect_info.
Reproduction
This occurs in production with mobile clients (e.g. Mobile Safari on iOS) that disconnect during LiveView mount — a common scenario on flaky mobile connections. Using Bandit as the HTTP server.
Observed on sentry 10.9.0, but the relevant code is unchanged through 12.0.3.
Suggested Fix
Wrap the get_connect_info(socket, :peer_data) call in a try/rescue that catches Bandit.TransportError and returns nil, allowing the hook to continue without peer data rather than crashing.
Stack Trace
Sentry.LiveView.on_mount hook errored out: ** (Bandit.TransportError) Unable to obtain peer_data
Environment
- sentry: 10.9.0 (code unchanged through 12.0.3)
- bandit: latest
- phoenix_live_view: ~> 1.0
- elixir: 1.19.5 / OTP 28
Metadata
Metadata
Assignees
Fields
Give feedbackProjects
Status