Skip to content

fix(calm-hub-ui): ignore the React Flow nodeTypes warning that StrictMode triggers in dev - #3560

Closed
Mittalnew wants to merge 1 commit into
finos:mainfrom
Mittalnew:fix-reactflow-nodetypes-warning
Closed

Mittalnew wants to merge 1 commit into
finos:mainfrom
Mittalnew:fix-reactflow-nodetypes-warning

Conversation

@Mittalnew

@Mittalnew Mittalnew commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3506

React Flow 11 reports error 002 ("new nodeTypes or edgeTypes object") when the keys of nodeTypes or edgeTypes change between renders. ArchitectureGraph, PatternGraph and DiffGraph already define them as module constants, but StrictMode runs React Flow's useMemo twice on mount in development, so the second run sees the same keys and warns. The warning is a false positive and only shows in development builds.

This adds a small onReactFlowError handler that skips error 002 and logs every other React Flow error the way React Flow does by default, and passes it to ReactFlow in the three graph components.

Testing: added two unit tests for the handler (error 002 is ignored, other errors are still logged). They pass, and eslint is clean on the changed folders. I did not run the Vite dev server against a backend, so I have not checked the console in a browser.

@Mittalnew
Mittalnew requested a review from a team as a code owner October 28, 2026 05:56
@github-actions github-actions Bot added the calm-hub-ui Affects `calm-hub-ui` label Oct 28, 2026

@jpgough-ms jpgough-ms left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler does not suppress the StrictMode 002 warning. See the inline comments.

// Our nodeTypes and edgeTypes are module constants, but StrictMode runs React Flow's
// useMemo twice on mount in development, so the second run warns. Every other
// error is still logged as React Flow would do by default.
export const onReactFlowError: OnError = (id, message) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler never receives error 002, so the warning still prints.

  • React Flow 11 raises 002 in useNodeOrEdgeTypes, inside a useMemo that runs during the first render.
  • The onError prop reaches the store later, in a useEffect in StoreUpdater (useDirectStoreUpdater). When StrictMode runs the memo twice on mount, the store still holds the default devWarn.
  • The types are module constants, so the memo does not run again. StoreUpdater calls reset() on unmount, so a remount does not help.

Reproduced: rendering <ReactFlow> in StrictMode with NODE_ENV=development logs the same two 002 warnings (nodeTypes and edgeTypes) with and without onError={onReactFlowError}.

The unit tests pass because they call the function directly. A test that renders ReactFlow in StrictMode and asserts no 002 warning would catch this.

React Flow 11 cannot set onError before the first render, so this approach cannot work. Options: close #3506 as a known dev-only false positive, or try a different approach. Also, if suppression did work, dropping every 002 would hide a real inline nodeTypes object added later.

if (id === '002') {
return;
}
console.warn(`[React Flow]: ${message} Help: https://reactflow.dev/error#${id}`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler logs in production builds, which the default does not. React Flow's devWarn logs only when process.env.NODE_ENV === 'development', so errors such as 004, 008 and 012 now reach the console in production. The code comment and PR description say the handler matches the default, which is not correct. Consider a guard on import.meta.env.DEV.

@jpgough-ms jpgough-ms left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few automated review comments, that I think we should fix. Thanks for the contribution.

@Mittalnew

Copy link
Copy Markdown
Contributor Author

Thanks for testing this and explaining it so clearly. You're right that the handler never sees error 002, since it fires on the first render, and that hiding every 002 could also hide a real nodeTypes problem. Since this looks like a dev-only false positive, I'm closing this PR. Thanks again for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calm-hub-ui Affects `calm-hub-ui`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calm-hub-ui: React Flow warns about new nodeTypes on each diagram mount in development

2 participants