You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(prefetch): drop the internal HTTP hop from every resource list prefetch
On a hard refresh of /files the folders painted first and the files a beat
later. Both are prefetched and hydrated together, so the files entry was never
reaching the client: each prefetch reached its own API route over an internal
HTTP request, prefetchQuery swallows a rejection, and shouldDehydrateQuery
drops an errored entry. One failed request silently shipped a page with that
list missing while its cheaper siblings hydrated fine — and nothing logged it.
The files list is the heaviest of the pair, so it lost that race first.
Every resource prefetch — files, home, tables, knowledge, and the shared
pinned/members chrome — now calls the data layer directly, matching
prefetchWorkspaceSidebar. Per page load that turns 5 internal HTTP round-trips,
each re-running session and membership authz, into 1 authz read plus N direct
reads.
Extracts listWorkspaceFilesWithShares, listPinnedItemsForViewer and
listKnowledgeBasesForViewer so each route and its prefetch fill the same query
key from one function and cannot drift. listKnowledgeBasesForViewer serializes
dates because the contract types them z.string(): reading the data layer
directly would otherwise cache Date objects that violate the declared type and
flip to strings on the first refetch.
The routes each authorized their own read, so each prefetch now verifies
membership once and caches nothing without access, leaving the client fetch to
get the real 403.
Also prefetches the viewer's pending invitations with the sidebar so the
switcher's "View invitations" entry is present the frame the menu opens, and
moves the invitation key factory into hooks/queries/utils so a server prefetch
can hydrate it without importing the emcn toast surface.
0 commit comments