Skip to content

Conversation

@lslezak
Copy link
Contributor

@lslezak lslezak commented Apr 22, 2025

Problem

agama-auto-registration-broken.webm
Firefox console log
Too many calls to Location or History APIs within a short timeframe. router.js:377:20
Too many calls to Location or History APIs within a short timeframe. router.js:388:22
Uncaught (in promise) DOMException: The operation is insecure.
    push router.js:388
    ve router.js:1739
    <anonymous> router.js:2215
    Ee router.js:2015
    n router.js:1862
    o index.js:917
    Ct index.js:1152
    React 3
    O scheduler.production.min.js:13
    D scheduler.production.min.js:14
index.js:2
Too many calls to Location or History APIs within a short timeframe. router.js:377:20
Too many calls to Location or History APIs within a short timeframe. router.js:388:22
Uncaught (in promise) DOMException: The operation is insecure.
    push router.js:388
    ve router.js:1739
    <anonymous> router.js:2215
    Ee router.js:2015
    n router.js:1862
    o index.js:917
    Ct index.js:1152
    React 11
    ql notifyManager.js:55
    n notifyManager.js:7
    batch notifyManager.js:29
    batch notifyManager.js:28
    r notifyManager.js:10
    batch notifyManager.js:27
    setTimeout handler*Gl notifyManager.js:2
    batch notifyManager.js:26
    batch notifyManager.js:44
    #s query.js:345
    setData query.js:52
    onSuccess query.js:247
    s retryer.js:45
    promise callback*f retryer.js:84
    start retryer.js:121
    fetch query.js:275
    #A queryObserver.js:179
    onSubscribe queryObserver.js:56
    subscribe subscribable.js:9
    Qs useBaseQuery.js:59
    React 12
    ql notifyManager.js:55
    n notifyManager.js:7
    batch notifyManager.js:29
    batch notifyManager.js:28
    r notifyManager.js:10
    batch notifyManager.js:27
    setTimeout handler*Gl notifyManager.js:2
    batch notifyManager.js:26
    batch notifyManager.js:44
    #s query.js:345
    setData query.js:52
    setQueryData queryClient.js:103
    ch status.ts:69
    dispatchEvent ws.ts:166
    dispatchEvent ws.ts:166
    onmessage ws.ts:82
index.js:2

Solution

  • It seems that the CLI tool is sending the changes too quickly so the Web UI uses History API a lot and Firefox browser denies the access. Add a short delay between selecting the product and registering it. In the web UI you cannot register until the UI processes all events and updates the screen, that takes some time. The CLI can send the requests much faster.
  • Handle the changed product event in Web UI, that helps to process it before registering the product so less events happen later. (It would be processed when registering the product but there would be too many events in a short time frame.)

Testing

  • Tested manually, works fine:
agama-auto-registration-fixed.webm

@lslezak lslezak merged commit a079a50 into master Apr 22, 2025
10 checks passed
@lslezak lslezak deleted the fix_broken_ui_after_registration branch April 22, 2025 13:04
@imobachgs imobachgs mentioned this pull request Apr 22, 2025
imobachgs added a commit that referenced this pull request Apr 22, 2025
@lslezak lslezak mentioned this pull request May 12, 2025
lslezak added a commit that referenced this pull request May 13, 2025
## Problem

- When registering the product from CLI the web UI was broken in Firefox

![Image](https://github.com/user-attachments/assets/90c12b88-14ed-4c83-9ae7-9fa006b0084c)
- See #2274
- It was fixed by a workaround:
#2281
- But we should find the real fix and remove that ugly workaround

## Debugging

To debug the issue I have reverted the #2281 fix and added a small
snippet which tracks using the History API into the `web/src/index.tsx`
file:

```js
let counter = 1;
const original = window.history.pushState;
window.history.pushState = function (data, unused, url) {
  console.log("pushState: ", counter, data, url);
  counter += 1;
  original.apply(this, [data, unused, url]);
};
```

That revealed that the History API was switching quickly between the
product selection page and the probing progress page:


![agama-too-many-push-states-orig](https://github.com/user-attachments/assets/380ffc30-12e7-44fe-aff1-883feb329d0c)

The Firefox browser has a limit of 200 History API calls within 10
seconds. After that an error is reported and an exception is raised.
That exception causes a crash in the React router resulting in empty
screen.

The problematic code was in the main application router:

```tsx
if (selectedProduct === undefined && location.pathname !== PRODUCT.root) {
  return <Navigate to={PRODUCT.root} />;
}

if (phase === InstallationPhase.Config && isBusy && location.pathname !== PRODUCT.progress) {
  return <Navigate to={PRODUCT.progress} />;
}
```

The problem happened when the selected product was not updated yet
(`selectedProduct === undefined`) but probing was already in progress
(`isBusy === true`). In that case these conditions caused switching
between the two paths as fast as possible. On my machine it was
switching about 1000 times per second as displayed in the log above.

A similar problem was present in the product selection page.

## Solution

- Handle this case explicitly, if that happens display the loading page
until the selected product is updated.

## Testing

- Tested manually, registration from CLI works fine even without that
delay workaround
- There are just few calls to the History API

![agama-too-many-push-states-fix1](https://github.com/user-attachments/assets/4f161cc8-3554-4444-89a6-149c5371f1f9)
@imobachgs imobachgs mentioned this pull request May 26, 2025
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.

3 participants