fix(utils): prevent false positive multiple instances warning in dev mode#7933
Merged
steveruizok merged 2 commits intomainfrom Mar 10, 2026
Merged
Conversation
…mode In Next.js dev mode, module re-evaluation causes each tldraw package to re-register itself via registerTldrawLibraryVersion(), but globalThis persists across re-evaluations. This leads to duplicate entries that trigger a spurious "multiple instances" warning even though only one copy of each library is actually loaded. Deduplicate registrations by skipping entries where the same name, version, and module type are already recorded. Genuine conflicts (different versions or mixed ESM/CJS) are still detected. Closes #4614
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
ds300
reviewed
Feb 19, 2026
Avoid false-positive multiple-instance warnings caused by Next.js Fast Refresh re-executing module code. Add an isNextjsDev() helper and only skip exact duplicate registrations when running in Next.js development mode (process.env.NODE_ENV === 'development' and global __NEXT_DATA__ present). Update tests to stub __NEXT_DATA__, toggle NODE_ENV and restore it, and add a new test that verifies duplicates still trigger a warning outside Next.js dev mode. Files changed: packages/utils/src/lib/version.ts, packages/utils/src/lib/version.test.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to fix a false positive "multiple instances" warning that fires in Next.js dev mode, this PR deduplicates registrations in
registerTldrawLibraryVersion().When Next.js re-evaluates modules on page refresh, each tldraw package re-registers itself via
registerTldrawLibraryVersion(). SinceglobalThis.__TLDRAW_LIBRARY_VERSIONS__persists across module re-evaluations, duplicate entries accumulate and trigger the "multiple instances" warning — even though only one copy of each library is loaded (all entries show the same version and same module type).The fix skips registration when an identical entry (same name, version, and module type) already exists. Genuine conflicts (different versions or mixed ESM/CJS) are still detected correctly.
Closes #4614
Change type
bugfixTest plan
Release notes
Note
Low Risk
Small, well-scoped change to warning/dedup logic gated to Next.js dev mode with unit test coverage; main risk is inadvertently suppressing a real duplicate only under those conditions.
Overview
Prevents false "multiple instances" warnings in Next.js dev mode by skipping re-registration when
registerTldrawLibraryVersionsees an exact duplicate entry (same package, version, and module type) during Fast Refresh.Adds
isNextjsDev()gating (checksNODE_ENV === 'development'and presence of__NEXT_DATA__) so duplicate tracking and warnings still occur in non-Next.js environments, and updates tests to cover both the Next.js dev dedupe behavior and the unchanged non-dev duplicate warning.Written by Cursor Bugbot for commit cc920c0. This will update automatically on new commits. Configure here.