Skip to content

Commit 6fe00a7

Browse files
Stop the sign-in page from reloading itself on a signed-out query
The query cache subscriber hard-redirects to /signin whenever a query fails with AUTH_REQUIRED or AUTH_EXPIRED. On staging the dev panel mounts on every page and its project meta hooks fetched the projects list while signed out, so the sign-in page itself received a 401 and reloaded in a loop. This only surfaced after #785, which let the domain error code reach the browser; the query had been failing silently before that. The subscriber now skips the redirect when already on /signin, and useProjectMeta no longer fetches for an empty projectId. Claude-Session: https://claude.ai/code/session_01Y7psErb45XSCJXpeZ9sipC
1 parent 71ff50a commit 6fe00a7

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

packages/web/src/lib/queryClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ function getQueryClient(): QueryClient {
5858
if (event.type === 'updated' && event.query.state.error) {
5959
const domainError = getDomainError(event.query.state.error);
6060
if (domainError?.code === 'AUTH_REQUIRED' || domainError?.code === 'AUTH_EXPIRED') {
61+
// A signed-out query failing on the sign-in page itself would otherwise reload it forever
62+
if (window.location.pathname === '/signin') return;
6163
window.location.href = '/signin';
6264
}
6365
}

packages/web/src/project/workspace-data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ export function useProjectMeta(projectId: string): ProjectMetaInfo {
521521
const { data } = useQuery({
522522
queryKey: queryKeys.projects.all,
523523
queryFn: () => getMyProjects(),
524+
// Callers outside a project (the dev panel on every page) pass '' and must not fetch
525+
enabled: Boolean(projectId),
524526
...QUERY_STABLE,
525527
});
526528
return useMemo(() => {

0 commit comments

Comments
 (0)