Skip to content

Conversation

@richard-to
Copy link
Collaborator

When Chrome encounters ERR_NETWORK_CHANGED or other network errors,
the SSE/WebSocket connection is terminated abnormally without sending
a STREAM_END signal. This caused the loading bar to remain visible
indefinitely because the isWaiting flag and timeout were never cleared.

This fix adds proper error handling:

  • For SSE: Added 'error' and 'abort' event listeners
  • For WebSocket: Updated 'onerror' and 'onclose' handlers
    Both now properly clear the isWaitingTimeout and reset the isWaiting
    and _isHotReloading flags to ensure the loading bar hides correctly.

Fixes #1312

When Chrome encounters ERR_NETWORK_CHANGED or other network errors,
the SSE/WebSocket connection is terminated abnormally without sending
a STREAM_END signal. This caused the loading bar to remain visible
indefinitely because the isWaiting flag and timeout were never cleared.

This fix adds proper error handling:
- For SSE: Added 'error' and 'abort' event listeners
- For WebSocket: Updated 'onerror' and 'onclose' handlers
Both now properly clear the isWaitingTimeout and reset the isWaiting
and _isHotReloading flags to ensure the loading bar hides correctly.

Fixes #1312
After a network error, the UI was not responding to events because:
1. SSE error handlers weren't setting status to CLOSED, so events
   got queued instead of re-initializing the connection
2. Error handlers weren't calling dequeueEvent() to process queued events

Now all error handlers (SSE error/abort, WebSocket error/close):
- Set status to CLOSED so dispatch() knows to re-initialize
- Process message queue to handle any pending responses
- Dequeue events to ensure pending user interactions are processed

This allows the connection to properly re-establish when the user
interacts after network connectivity is restored.
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.

Chrome ERR_NETWORK_CHANGED error can cause loading bar to keep going and it won't reset

3 participants