Skip to content

Unnecessary reconnection due to visibilitychange #6578

@avs-doom

Description

@avs-doom

Hi!

"phoenix": "1.8.3"

I noticed that after I disconnected the connection via socket.disconnect, left the tab and returned, phoenix returned the socket connection back, this is extremely strange behavior that I did not expect. Is there any way to prohibit reconnection using this case? Judging by the code, phoenix is constantly reconnecting, regardless of whether it was forcibly terminated or whether the connection was lost for other reasons

phxWindow.addEventListener("visibilitychange", () => {
        if (document.visibilityState === "hidden") {
          this.pageHidden = true;
        } else {
          this.pageHidden = false;
          if (!this.isConnected()) {
            this.teardown(() => this.connect());
          }
        }
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions