-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
When viewing an Order in the Admin Dashboard, the console throws a runtime error because the React Query queryFn
in useTransitionOrderToState
may return undefined
.
TanStack Query explicitly disallows undefined
results.
To Reproduce
Steps to reproduce the behavior:
- Open the Admin Dashboard.
- Navigate to an Order that does not have a
Modifying
transition in its history. - Open the browser console.
- See error.
Expected behavior
The hook should always return a defined value (null
if no previous state is found) so that React Query does not throw.
No console error should appear.
Actual behavior
The function can return undefined
, which causes React Query to throw:
Query data cannot be undefined. Please make sure to return a value other than undefined from your query function.
Affected query key: ["orderPreModifyingState","<id>"]
Screenshots/Videos
N/A
Error logs
Query data cannot be undefined. Please make sure to return a value other than undefined from your query function.
Affected query key: ["orderPreModifyingState","14"]
Environment (please complete the following information):
- @vendure/core version: 3.4.1
- Nodejs version: 22.16.0
- Database: sqlite
- Operating System: Linux (Ubuntu 24.04)
- Browser: Firefox
- Package manager: npm
Configuration
// No special configuration needed to reproduce
Minimal reproduction
Open an Order in the Admin Dashboard that does not contain a Modifying
transition in its history.
The error will appear in the console.
Workaround
Locally patch the hook to ensure that the query function always returns a concrete value:
return (modifyingEntry?.data?.from as string | undefined) ?? null;
Also add:
useQuery<string | null>
typingenabled: !!orderId
placeholderData: null
Additional context
- The bug is consistent and occurs whenever an order has no
Modifying
transition entry. - Fixing this improves robustness of the dashboard and avoids runtime errors.
I intend to work on a fix for this issue and submit a PR.