Skip to content

Frequent websocket disconnects on Firefox #2684

Open
@ehuss

Description

@ehuss

Problem

I am having problems with websocket disconnects on the mdbook server on Firefox. I see the following in the console:

The connection to ws://localhost:3000/__livereload was interrupted while the page was loading.

I have not been able to identify what causes this to happen. It happens very frequently, often about a minute after loading a page. However, it is quite random and there isn't an obvious cause.

This does not appear to happen on Chrome or Safari, but I have not tested those very much. I also have not had a chance to see if this happens on other systems.

This started happening within the past 3-6 months, I do not recall this being an issue in the past.

There's a variety of things to investigate:

  • Is this reproducible on other systems or other browsers? Is there something unique in my setup? Is it caused by some extension?
  • If this is unique to Firefox, is there a known issue about this?
  • Is there something about our Websocket implementation that is causing this?
  • Is this reproducible on older versions of mdbook? Was this introduced by some update?

Steps

  1. Load a page
  2. Wait a few minutes
  3. Notice the websocket error, and the page will not reload when there are changes.

Possible Solution(s)

  • If this is a bug in Firefox, see if that has a fix?
  • If this is a problem in the websocket implementation, see if that can be fixed.
  • Perhaps look into some kind of keepalive? The websocket protocol has a native keepalive, but my understanding is that browsers don't really handle that? If not, maybe just sending a small ping message periodically could help.
  • Consider reconnecting if the connection is dropped? There are some potential issues with that, for example if you stop the server, and then restart it for another book. Do we want the page to reload in that scenario, or stay with the original book still open?

Notes

Firefox 137.0.2 on macOS.

Version

mdbook v0.4.48

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: A bug, incorrect or unintended behaviorCommand-serveCommand: serve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions