Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation about why it stopped to work suddenly since updating the last version of NextJs #9

Open
JesusDR01 opened this issue Sep 24, 2024 · 7 comments

Comments

@JesusDR01
Copy link

Hello, for those who are using the latest version of Next and the extension stopped working suddenly, here is the explanation:

The NextJs team have launched recently the 14.2.13 package, so everyone with

"next": "^14.1.0", in their package.json will face the extension suddenly stopped working (as it will be updated to a newer version by using ^)

Explanation about why this issue is happening:

NextJs team updated React right before 14.1.1-canary.45 version

image

This update, includes the commit facebook/react#28265

Comments from the author:
image

This commit is deleting _debugSource, here is the explanation of what is actually happening:

facebook/react#29092 (comment)

image

Using NextJs Version 14.1.1-canary.44 (before the ReactJs release):

image

Using NextJs Version 14.1.1-canary.45 (after the ReactJs release):

image

As the _debugSource is not there in the 14.1.1-canary.45 version, we cannot make use of the _debugSource to open the file in vscode.

NextJs developers who updated to the last version cannot make use of the extension till new updates on react fiber.

@nandorojo
Copy link

@JesusDR01 thanks for sharing this, is there a workaround known?

@JesusDR01
Copy link
Author

JesusDR01 commented Oct 21, 2024

@JesusDR01 thanks for sharing this, is there a workaround known?

Just use in your package.json:

"next": "14.1.0",

Until React and React developer tools fix this in a future version

@nandorojo
Copy link

Got it, yeah I could try downgrading. That said, I wonder if there's a way to patch the source code in this repo to fix it, or if downgrading is the only option.

@nandorojo
Copy link

Next.js launched 15 an hour ago, I wonder if that fixes it

@nandorojo
Copy link

I tried Next.js 14.1.0 but I only see this:

image

Not sure what's up with it, I'll see if 15 helps

@nandorojo
Copy link

Looks like _debugSource is also inside of _debugOwner, so this code fixes it:

export const findFiberByHostInstance = (
  target: HTMLElement
): { _debugSource: DebugSource } | null => {
  if (!checkDevtoolsGlobalHook()) return null;

  const renderer = getDevtoolsGlobalHookRenderer();
  if (!renderer) return null;

  const fiber = renderer.findFiberByHostInstance(target) || null;

  console.log("[detectorino] fiber", fiber);

  if (fiber) {
    // nandorojo: I had to add this in to fix this
    // https://github.com/hand-dot/react-inspector/issues/9
    fiber._debugSource ??= fiber._debugOwner?._debugSource ?? null;
  }

  return fiber?._debugSource ? fiber : null;
};

@JesusDR01
Copy link
Author

Looks like _debugSource is also inside of _debugOwner, so this code fixes it:

export const findFiberByHostInstance = (
  target: HTMLElement
): { _debugSource: DebugSource } | null => {
  if (!checkDevtoolsGlobalHook()) return null;

  const renderer = getDevtoolsGlobalHookRenderer();
  if (!renderer) return null;

  const fiber = renderer.findFiberByHostInstance(target) || null;

  console.log("[detectorino] fiber", fiber);

  if (fiber) {
    // nandorojo: I had to add this in to fix this
    // https://github.com/hand-dot/react-inspector/issues/9
    fiber._debugSource ??= fiber._debugOwner?._debugSource ?? null;
  }

  return fiber?._debugSource ? fiber : null;
};

is this using NextJs 15 or 14.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants