fix(election): pass id to ElectionProvider so refetchInterval triggers background refetches#1646
Open
argos-code wants to merge 11 commits into
Open
Conversation
…ting that after refetchInter... Signed-by: argos-code <argos-code@users.noreply.github.com>
…lection` prop with an initia... Signed-by: argos-code <argos-code@users.noreply.github.com>
…er usage; apply the same ini... Signed-by: argos-code <argos-code@users.noreply.github.com>
…ng T002; run full pnpm test ... Signed-by: argos-code <argos-code@users.noreply.github.com>
…om test discovery - Add argos.yml with install_commands to set up Node 22 and pnpm in the validation container, then run pnpm install and chakra:typegen. - Add .pnpm-store to vitest exclude list so pnpm store temp test files are not discovered during the test run. - Remove unused ReactNode import from dashboard process view test. Signed-by: argos-code <argos-code@users.noreply.github.com>
…mlink When Node 22 is installed from NodeSource apt, npm's global prefix is /usr (not /usr/local), so `npm install -g pnpm` places the binary at /usr/bin/pnpm. Some validation environments may have a PATH that does not resolve /usr/bin first. Add an explicit `ln -sf` to guarantee pnpm is available at /usr/local/bin/pnpm, which is always early in PATH. Also remove the now-redundant separate `pnpm chakra:typegen` step since `pnpm install` already runs it via the prepare script on Node 22. Signed-by: argos-code <argos-code@users.noreply.github.com>
Replace the NodeSource apt-get + npm global install chain (which was failing silently in the orchestrator's container) with direct downloads from official distribution mirrors: - Node 22.22.2 from nodejs.org/dist extracted into /usr/local - pnpm 10.16.1 standalone binary from pnpm GitHub releases to /usr/local/bin/pnpm Both binaries land at known /usr/local paths that are always on PATH. Node 22 is required because Vite 7 is ESM-only (Node 20+ required) and because pnpm install runs chakra:typegen which uses File (Node 20+ global). Signed-by: argos-code <argos-code@users.noreply.github.com>
…verage Previous attempts installed binaries into /usr/local/bin, which is not present in the restricted PATH used by the orchestrator's validation scripts (/argos-validate/cmd-N.sh). Install both tools into /usr/bin which is in every PATH: - Node 22.22.2 tarball extracted to /usr (puts node/npm at /usr/bin/node) - pnpm 10.16.1 standalone binary written to /usr/bin/pnpm pnpm install then runs the prepare script (chakra:typegen) under Node 22 which has the File global, fixing the tsc type errors from stale Chakra theme types. Signed-by: argos-code <argos-code@users.noreply.github.com>
Use `npm install -g pnpm@10.16.1 --prefix /usr` instead of downloading the standalone binary from github.com — avoids network reachability issues and places pnpm at /usr/bin/pnpm via the npm registry. Switch Node 22 tarball from .tar.xz to .tar.gz for ~6x faster extraction (0.9s vs ~6s), reducing total setup time. Signed-by: argos-code <argos-code@users.noreply.github.com>
The orchestrator validation suite runs `tsc` as a standalone command outside of pnpm scripts. Add `npm install -g typescript@5.9.3 --prefix /usr` to install_commands so the binary is available at /usr/bin/tsc. Signed-by: argos-code <argos-code@users.noreply.github.com>
Signed-by: argos-code <argos-code@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an election is pre-fetched by the router loader and passed directly to
ElectionProvidervia theelectionprop, the provider's internal React Query hook never receives a query key (noidprop), so it staysenabled: false. This meansrefetchInterval: 15_000inqueryOptionssilently does nothing — the election data shown in the dashboard process view and the public process page goes stale after the initial load.The fix is a one-line addition in each component: pass
id={election.id}alongside the existingelectionprop. Withidpresent, React Query is enabled and treatselectionasinitialData, so the first render is instant (no loading flash) and subsequent refetches fire on the configured interval.Linked issue
Closes #1609
Changes
src/elements/dashboard/processes/view.tsx— addid={election.id}to<ElectionProvider>src/elements/processes/PublicPage.tsx— same one-line fixsrc/elements/dashboard/processes/view.test.tsx— new test assertingElectionProviderreceives the correctidpropsrc/elements/processes/PublicPage.test.tsx— mirror test for the public pagevitest.config.ts— exclude.pnpm-storefrom test discovery (pnpm store dropped temp test files into its cache dir)argos.yml— encode Node 22 + pnpm + tsc install steps for the validation containerTests run
Risks and review focus
initialDatafreshness: whenelectionis passed alongsideid, React Query uses it asinitialData. Depending on thestaleTimeconfigured inElectionProvider's internals, the first background refetch may be deferred. In practice therefetchIntervaloverrides this — confirmed by the tests — but reviewers should be aware that the exact timing of the first background request depends on the provider's internalstaleTime.@vocdoni/react-components: the fix is entirely at the call site. If the provider is updated upstream and changes how it handles concurrentid+electionprops, these sites will need re-checking.Notes for maintainers
The root cause is that
ElectionProviderrequiresidto enable its query; without it the hook is a no-op regardless ofqueryOptions. Both affected components already passedelection(for the initial render) but omittedid(which would have enabled polling). The issue reporter's suggested approach of recovering "merge prop behaviour" is not needed — the existing provider API handles this correctly onceidis supplied.