Skip to content

Fix row actions on instance NICs table closing when polling - #2460

Merged
david-crespo merged 1 commit into
mainfrom
fix-nics-table-polling-close
Sep 20, 2024
Merged

david-crespo merged 1 commit into
mainfrom
fix-nics-table-polling-close

Conversation

@david-crespo

@david-crespo david-crespo commented Sep 19, 2024 •

Copy link
Copy Markdown
Collaborator

Same deal as #2453. Diff is much better with whitespace hidden since there's a big indent involved.

2024-09-19-stop-instance-nics-actions.mp4

@vercel

vercel Bot commented Sep 19, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Sep 19, 2024 9:47pm

@david-crespo david-crespo changed the title Fix row actions on instnace NICs table closing when polling Fix row actions on instance NICs table closing when polling Sep 20, 2024
@david-crespo
david-crespo merged commit da7fe32 into main Sep 20, 2024
@david-crespo
david-crespo deleted the fix-nics-table-polling-close branch September 20, 2024 21:12
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Oct 3, 2024
oxidecomputer/console@5561f28...073471c

* [073471c4](oxidecomputer/console@073471c4) mock api: disks are created straight into detached state
* [612ec90c](oxidecomputer/console@612ec90c) oxidecomputer/console#2485
* [614f1bb5](oxidecomputer/console@614f1bb5) oxidecomputer/console#2466
* [df2dc14c](oxidecomputer/console@df2dc14c) bump vite related deps for a weird vuln
* [a030b9e0](oxidecomputer/console@a030b9e0) oxidecomputer/console#2464
* [dec48497](oxidecomputer/console@dec48497) oxidecomputer/console#2461
* [e46216aa](oxidecomputer/console@e46216aa) oxidecomputer/console#2482
* [0d897efe](oxidecomputer/console@0d897efe) oxidecomputer/console#2479
* [f88790db](oxidecomputer/console@f88790db) oxidecomputer/console#2478
* [d634c8f0](oxidecomputer/console@d634c8f0) oxidecomputer/console#2477
* [eeaa14c3](oxidecomputer/console@eeaa14c3) oxidecomputer/console#2475
* [5ece6e18](oxidecomputer/console@5ece6e18) oxidecomputer/console#2467
* [4b699e01](oxidecomputer/console@4b699e01) oxidecomputer/console#2448
* [9c9dc149](oxidecomputer/console@9c9dc149) oxidecomputer/console#2465
* [1aa0fc9b](oxidecomputer/console@1aa0fc9b) oxidecomputer/console#2463
* [57db4054](oxidecomputer/console@57db4054) oxidecomputer/console#2462
* [da7fe328](oxidecomputer/console@da7fe328) oxidecomputer/console#2460
* [e0d52efd](oxidecomputer/console@e0d52efd) oxidecomputer/console#2437
* [1625d02a](oxidecomputer/console@1625d02a) oxidecomputer/console#2458
* [fd82458e](oxidecomputer/console@fd82458e) oxidecomputer/console#2457
* [7daaa337](oxidecomputer/console@7daaa337) oxidecomputer/console#2453
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Oct 3, 2024
oxidecomputer/console@5561f28...073471c

* [073471c4](oxidecomputer/console@073471c4)
mock api: disks are created straight into detached state
* [612ec90c](oxidecomputer/console@612ec90c)
oxidecomputer/console#2485
* [614f1bb5](oxidecomputer/console@614f1bb5)
oxidecomputer/console#2466
* [df2dc14c](oxidecomputer/console@df2dc14c)
bump vite related deps for a weird vuln
* [a030b9e0](oxidecomputer/console@a030b9e0)
oxidecomputer/console#2464
* [dec48497](oxidecomputer/console@dec48497)
oxidecomputer/console#2461
* [e46216aa](oxidecomputer/console@e46216aa)
oxidecomputer/console#2482
* [0d897efe](oxidecomputer/console@0d897efe)
oxidecomputer/console#2479
* [f88790db](oxidecomputer/console@f88790db)
oxidecomputer/console#2478
* [d634c8f0](oxidecomputer/console@d634c8f0)
oxidecomputer/console#2477
* [eeaa14c3](oxidecomputer/console@eeaa14c3)
oxidecomputer/console#2475
* [5ece6e18](oxidecomputer/console@5ece6e18)
oxidecomputer/console#2467
* [4b699e01](oxidecomputer/console@4b699e01)
oxidecomputer/console#2448
* [9c9dc149](oxidecomputer/console@9c9dc149)
oxidecomputer/console#2465
* [1aa0fc9b](oxidecomputer/console@1aa0fc9b)
oxidecomputer/console#2463
* [57db4054](oxidecomputer/console@57db4054)
oxidecomputer/console#2462
* [da7fe328](oxidecomputer/console@da7fe328)
oxidecomputer/console#2460
* [e0d52efd](oxidecomputer/console@e0d52efd)
oxidecomputer/console#2437
* [1625d02a](oxidecomputer/console@1625d02a)
oxidecomputer/console#2458
* [fd82458e](oxidecomputer/console@fd82458e)
oxidecomputer/console#2457
* [7daaa337](oxidecomputer/console@7daaa337)
oxidecomputer/console#2453
david-crespo added a commit that referenced this pull request Sep 3, 2026
…ty (#3364)

The Firefox run on the audit log merge to main failed `Silo IP pools` on
all three attempts, each time in `clickRowAction` on the menu item, with
Chrome and Safari passing:


https://github.com/oxidecomputer/console/actions/runs/33767277998/attempts/1

I could not repro locally with the code as-is, but I can make it happen
by adding a delay in the mock API (see below). `SiloIpPoolsTab` fetches
the silo's pools twice: the paginated list that the table renders, and a
second `useQuery` for all of them, which the "Make default" confirm
modal uses to find the existing default for the same IP version and type
so it can warn that it will be replaced. `makeActions` depends on that
second result. The sequence in the test:

1. The test unlinks a pool, and the mutation's `onSuccess` invalidates
both the paginated list and the all-pools list.
2. The test waits for the unlinked row to disappear, which happens as
soon as the paginated refetch lands, and then opens the next row's menu.
3. If the all-pools refetch has already landed by then, nothing happens.
If it lands after the menu is open, it gives `makeActions` a new
identity.
4. `useColsWithActions` builds a new actions column with a new inline
`cell` closure.
5.
[`flexRender`](https://github.com/TanStack/table/blob/ab2819c/packages/react-table/src/index.tsx#L18-L27)
renders a function `cell` as a component, so a new function is a new
element type and React remounts the whole cell.
6. The open menu is unmounted along with the cell and comes back closed,
so the menu item Playwright was about to click is gone.

To confirm this, I added a 150ms delay to the mock all-pools response so
it lands right around the time the test opens the menu. On main, the e2e
test fails 5 out of 42 runs on Firefox with exactly the CI error,
detached menu item and all, at the same line. With the fix and the same
delay, it passes 24 out of 24. A longer delay like 1.5s makes the test
pass again on main because Playwright opens the menu and clicks before
the refetch lands, which is also why the test has been fine locally.
With the 1.5s delay and a throwaway e2e test that holds the menu open
across it, the menu closed before the fix and stayed open after.

The fix is to make the more actions button cell a single module-level
`ActionsCell` component and pass `makeActions` and `copyIdLabel` through
column `meta` instead of closing over them in a dynamic cell definition.
The element type is then stable no matter how often the callback or the
columns array changes identity, so it fixes every table using
`getActionsCol` without touching any call sites. The browser spec opens
a row menu, rerenders with a new `makeActions`, and asserts the menu is
still open. It failed in all three browsers before the fix.

This is the same mechanism behind the polling-closes-the-menu problems
in #2112, #2460, and #2816. Each of those was fixed by memoizing
`makeActions` or the columns array carefully enough to keep the closure
identity stable. With a stable cell component, that memoization is only
a render-count optimization, so I softened the doc comments on
`useColsWithActions`. The `instanceState` hack on NIC rows from #2460
could be unwound now, but I've left that for a followup.

This branch was successfully deployed

1 active deployment
Preview — 4bf56c0f Deployed Sep 19, 2024 by vercel[bot]
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.

1 participant