{"record":{"id":"c52a348f0c8c7a08","repo":"facebook/relay","slug":"userefetchablefragmentnode-unexpected-action-type-c52a34","errorCode":null,"errorMessage":"useRefetchableFragmentNode: Unexpected action type","messagePattern":"useRefetchableFragmentNode: Unexpected action type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-relay/relay-hooks/useRefetchableFragmentInternal.js","lineNumber":158,"sourceCode":"        onComplete: action.onComplete,\n        refetchEnvironment: action.refetchEnvironment,\n        refetchQuery: action.refetchQuery,\n        renderPolicy: action.renderPolicy,\n      };\n    }\n    case 'reset': {\n      return {\n        fetchPolicy: undefined,\n        mirroredEnvironment: action.environment,\n        mirroredFragmentIdentifier: action.fragmentIdentifier,\n        onComplete: undefined,\n        refetchQuery: null,\n        renderPolicy: undefined,\n      };\n    }\n    default: {\n      action.type as empty;\n      throw new Error('useRefetchableFragmentNode: Unexpected action type');\n    }\n  }\n}\n\nhook useRefetchableFragmentInternal<\n  TQuery extends OperationType,\n  TKey extends ?{readonly $data?: unknown, ...},\n>(\n  fragmentNode: ReaderFragment,\n  parentFragmentRef: unknown,\n  componentDisplayName: string,\n): ReturnType<TQuery, TKey, InternalOptions> {\n  const parentEnvironment = useRelayEnvironment();\n  const {refetchableRequest, fragmentRefPathInResponse, identifierInfo} =\n    getRefetchMetadata(fragmentNode, componentDisplayName);\n  const fragmentIdentifier = getFragmentIdentifier(\n    fragmentNode,\n    parentFragmentRef,","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/packages/react-relay/relay-hooks/useRefetchableFragmentInternal.js#L140-L176","documentation":"useRefetchableFragmentNode manages refetch state through a useReducer whose reducer handles a fixed set of action types (e.g. 'refetch', 'loading', 'reset'). Reaching the default branch means an action with an unknown type was dispatched — Relay treats this as an internal invariant violation / bug in Relay or in a wrapper that dispatches custom actions into its state.","triggerScenarios":"The reducer in useRefetchableFragmentInternal.js receives an action whose type matches none of its cases — typically caused by a Relay version mismatch (react-relay dispatching action shapes a different relay-runtime/relay-hooks version doesn't know), or code monkey-patching/forwarding foreign actions into the hook's reducer.","commonSituations":"Mismatched versions of react-relay, relay-runtime, and relay-hooks packages in node_modules (duplicated installs); patched or mocked Relay internals in tests; custom forks of useRefetchableFragment that emit new action types.","solutions":["Run 'npm ls react-relay relay-runtime' (or yarn why) and deduplicate so react-relay and relay-runtime are the same version","Delete node_modules and lockfile and reinstall to clear duplicate relay packages","Remove any custom code/tests that dispatch unknown actions into Relay's internal reducer","If reproducible on matching versions, file a Relay bug with a reproduction (this is an internal invariant)"],"exampleFix":"// before (package.json)\n\"react-relay\": \"14.1.0\",\n\"relay-runtime\": \"13.2.0\"\n// after\n\"react-relay\": \"14.1.0\",\n\"relay-runtime\": \"14.1.0\"","handlingStrategy":"validation","validationCode":"import pkg from 'react-relay/package.json';\nimport rt from 'relay-runtime/package.json';\nif (pkg.version !== rt.version) throw new Error('react-relay/relay-runtime version mismatch: ' + pkg.version + ' vs ' + rt.version);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin react-relay and relay-runtime to the exact same version in package.json","Run npm ls relay-runtime in CI to detect duplicates","Do not dispatch custom actions into Relay internal hooks","Wrap refetch calls in an ErrorBoundary so invariant crashes degrade gracefully"],"tags":["react","use-refetchable-fragment","reducer","internal-invariant","version-mismatch"],"backgroundTag":"relay-internal-invariant","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}