Skip to content

Forum (discussion) page loops endlessly when Flarum auth fails #5310

@Ma77Ball

Description

@Ma77Ball

Describe the bug

The Forum / discussion page (/dashboard/user/discussion) causes the frontend to loop over and over again — it repeatedly fires forum/api/token (auth) and forum/api/users (register) requests in an infinite cycle instead of loading the forum.

Root cause

forumLogin() in frontend/src/app/dashboard/component/dashboard.component.ts (lines ~205-226):

forumLogin() {
  if (!document.cookie.includes("flarum_remember") && this.isLogin) {
    this.flarumService.auth().pipe(untilDestroyed(this)).subscribe({
      next: (response: any) => {
        document.cookie = `flarum_remember=${response.token};path=/`;
      },
      error: (err: unknown) => {
        if ([404, 500].includes((err as HttpErrorResponse).status)) {
          this.displayForum = false;
        } else {
          this.flarumService.register()
            .pipe(untilDestroyed(this))
            .subscribe(() => this.forumLogin()); // recursive call
        }
      },
    });
  }
}

When auth() fails with any status other than 404/500 (e.g. network/CORS failure with status 0, or 401), the error branch calls register() and then recursively calls forumLogin(). Since auth() keeps failing, the cookie is never set and the guard never short-circuits, so it loops forever — auth → register → auth → register → … This is the observed repeated looping.

Image

Expected behavior

The forum login should attempt registration at most once and stop on persistent failure (hide the forum / surface an error) rather than retrying indefinitely.

Steps to reproduce

  1. Have the Flarum forum service unreachable or returning a non-404/500 error.
  2. Log in and open the Forum (discussion) page.
  3. Observe the network tab: forum/api/token and forum/api/users fire repeatedly without end.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions