Skip to content

Segment Explorer can't Open in Editor when Next.js app is part of a monorepo #85695

@jarrodldavis

Description

@jarrodldavis

Link to the code that reproduces this issue

https://github.com/vercel/turborepo/tree/main/examples/basic

To Reproduce

  1. Use npx create-turbo@latest as instructed in the example's README
  2. Select pnpm as the package manager
  3. Start the apps using pnpm dev
  4. Open the docs site at https://localhost:3001
  5. Open the Segment Explorer from the Next.js Dev Tools (click the button in the bottom left corner and select Route Info)
  6. Hover over either layout.tsx or page.tsx, then click on the code icon

Current vs. Expected behavior

I expect my editor (in my case, Visual Studio Code) to open the selected file. Instead, nothing happens. Inspecting Chrome Dev Tools, I see a 404 error from a request to http://localhost:3001/__nextjs_launch-editor?file=%2Fapps%2Fdocs%2Fapp%2Flayout.tsx&isAppRelativePath=1.

Provide environment information

Operating System:
  Platform: linux
  Arch: arm64
  Version: #1 SMP Thu Aug 14 19:26:13 UTC 2025
  Available memory (MB): 15973
  Available CPU cores: 12
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.0.0
Relevant Packages:
  next: 16.0.2-canary.4 // Latest available version is detected (16.0.2-canary.4).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Notably, the path given to /__nextjs_launch-editor is from the root of the monorepo rather than from the Next.js app's app directory, which I think is what's causing the issue, given this code:

function openInEditor({ filePath }: { filePath: string }) {
const params = new URLSearchParams({
file: filePath,
// Mark the file path is relative to the app directory,
// The editor launcher will complete the full path for it.
isAppRelativePath: '1',
})
fetch(
`${
process.env.__NEXT_ROUTER_BASEPATH || ''
}/__nextjs_launch-editor?${params.toString()}`
)
}

} else if (pathname === '/__nextjs_launch-editor') {
const isAppRelativePath = searchParams.get('isAppRelativePath') === '1'
let openEditorResult
if (isAppRelativePath) {
const relativeFilePath = searchParams.get('file') || ''
const appPath = path.join(
'app',
isSrcDir ? 'src' : '',
relativeFilePath
)
openEditorResult = await openFileInEditor(appPath, 1, 1, projectPath)
} else {

As instructed by next info, I updated to the latest canary version of Next.js and was still able to reproduce the issue.

I tried changing turbopack.root in next.config.ts, assuming that this is being defaulted to the monorepo root due to where pnpm-lock.yaml is placed. Unfortunately, this causes other issue, namely that Turbopack can no longer resolve next/package.json (probably because of how pnpm symlinks packages).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions