Thanks to visit codestin.com
Credit goes to github.com

Skip to content

h3 version mismatch: Nitro server event handler using h3 v1.x conflicts with compiler auto-imported proxyRequest from hoisted h3 v2.x #35132

Description

@pampas9000

Environment

  • Operating System: macOS (Darwin)
  • Package Manager: [email protected]
  • Nuxt Version: 4.4.6
  • Nitro Version: 2.13.4
  • Vite Version: 7.3.3
  • @vitejs/devtools: 0.1.24

Reproduction

  1. Create a Nuxt 4.4.x project inside a monorepo setup.
  2. Install nuxt and add @vitejs/devtools (e.g. ^0.1.24) as a devDependency.
  3. Run bun install. Verify that [email protected] is resolved and hoisted to the parent/root node_modules/h3.
  4. Create a server API route (e.g. server/api/[...].ts) to proxy incoming requests:
export default defineEventHandler(async (event) => {
  const targetUrl = `http://127.0.0.1:8080${event.path}`
  
  return proxyRequest(event, targetUrl, {
    fetchOptions: {
      redirect: 'manual',
    }
  })
})

Describe the bug

In a monorepo setup (or when running installations that hoist devDependencies to root node_modules), if a dependency like @vitejs/devtools pulls h3 version 2.0.1-rc.22 (pre-release version), it gets hoisted to the top-level node_modules/h3.

During building/development, Nitro's compiler resolves auto-imported utilities like proxyRequest from h3 v2.x (which is found at the root/top-level node_modules). However, Nitro's internal runtime is running on [email protected] and instantiates the request event object using the 1.x branch structure.

Because [email protected] introduces signature changes and expects event.req.headers to be a Web API Headers instance supporting .entries(), calling proxyRequest(event, ...) throws a runtime error:
TypeError: event.req.headers.entries is not a function or its return value is not iterable

Nitro should enforce that auto-imported runtime utilities like proxyRequest are resolved from the pinned h3 version matching Nitro's own runtime version (1.x at this moment) instead of allowing hoisted/external packages to hijack the imports.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions