Skip to content

[Bug?]: TypeError: Invalid URL on production builds #2124

Description

@mckeenicholas

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When loading / (or any url for that matter) on the production build of the default template, an error 500 is returned with the following output

TypeError: Invalid URL
    at new URL (node:internal/url:819:25)
    ... 8 lines matching cause stack trace ...
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
  cause: TypeError: Invalid URL
      at new URL (node:internal/url:819:25)
      at get _url (file://~/solid-project/.output/server/node_modules/srvx/dist/_chunks/_url.mjs:43:16)
      at get pathname (file://~/solid-project/.output/server/node_modules/srvx/dist/_chunks/_url.mjs:75:43)
      at H3._findRoute (file://~/solid-project/.output/server/chunks/virtual/entry.mjs:665:62)
      at H3.handler (file://~/solid-project/.output/server/chunks/virtual/entry.mjs:584:23)
      at H3._request (file://~/solid-project/.output/server/chunks/virtual/entry.mjs:563:30)
      at H3.fetch (file://~/solid-project/.output/server/chunks/virtual/entry.mjs:551:16)
      at Object._webHandler [as handler] (file://~/solid-project/.output/server/chunks/virtual/entry.mjs:677:10)
      at file://~/solid-project/.output/server/chunks/nitro/nitro.mjs:1490:43
      at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
    code: 'ERR_INVALID_URL',
    input: '/'
  },
  status: 500,
  statusText: undefined,
  headers: undefined,
  data: undefined,
  body: undefined,
  unhandled: true
}

(Absolute paths have been redacted and replaced with ~)

The browser dispalys: {"status":500,"unhandled":true,"message":"HTTPError"}.

Issue appears to be from trying to load a relative path into NativeURL, however I don't know enough about how nitro/the router works to look further.

Expected behavior 🤔

Should load the base route of the project.

Steps to reproduce 🕹

Steps:

  1. Run npm create solid@latest
  2. Select SolidStart, v2, typescript, basic
  3. Run cd solid-project, npm i, npm run build
  4. Run node .output/server/index.mjs
  5. Open localhost:3000 in the browser

Same issue exists by following the above steps but with bun.

Context 🔦

Ran into this issue when trying to build a fullstack app, coundln't find any info online, and I assume its not my issue since it exists in a template project.

Your environment 🌎

System:
  OS: Ubuntu 22.04.5 LTS (WSL2)
  CPU: Intel i5 13600k
Binaries:
  Node: v24.13.1
  npm: 11.8.0
  Bun: 1.3.10
package.json
  "@solidjs/router": "^0.15.0"
  "@solidjs/start": "2.0.0-alpha.2"
  "@solidjs/vite-plugin-nitro-2": "^0.1.0"
  "solid-js": "^1.9.5"
  "vite": "7"

Activity

  1. huseeiin commented on Apr 3, 2026

    @huseeiin
    Contributor

    make sure you don't have multiple versions of h3 installed

  2. marknelissen commented on Apr 10, 2026

    @marknelissen

    The multiple h3 seem to be the root cause, but is created by @solidjs/vite-plugin-nitro-2 pulling in another version than @solidjs/start.

    Image

    I think a new compatible version of vite-plugin-nitro-2 needs to be released. Even the 0.2.0 (with alfa flag) is pulling in the 1.x version of h3, instead of the 2.x-rc

  3. marknelissen commented on Apr 10, 2026

    @marknelissen

    The workaround I have found is switching from npm to pnpm as package manager. Then it works.

  4. Kalcode commented on Apr 10, 2026

    @Kalcode

    From my side, I think I'm hitting the same bug on a production SolidStart v2 app, and from what I can see the break seems to happen here:

    The generated .output/server/chunks/virtual/entry.mjs contains h3 v2's fromWebHandler:

    function fromWebHandler(handler) {
      return function _webHandler(event) {
        return handler(event.req, event.context);
      };
    }

    As far as I can tell this _webHandler ends up being invoked by nitro.mjs, which from what I can see still uses h3 v1 internally. In h3 v1, event.req appears to be a deprecated getter:

    /** @deprecated Please use `event.node.req` instead. */
    get req() {
      return this.node.req;  // Node.js IncomingMessage
    }

    So if I'm reading this correctly, _webHandler receives an h3 v1 event and pulls event.req, which returns a Node.js IncomingMessage rather than a Web Request. That then gets passed to the h3 v2 handler, which does new FastURL(req.url) where req.url is just "/" (since Node IncomingMessages use path-only URLs). FastURL seems to store "/" as the href, and when the pathname getter falls back to new NativeURL(this.href) you end up with new URL("/") → TypeError: Invalid URL.

    So from what I can see, the issue looks like the h3 v1 ↔ h3 v2 bridge in the node-server preset isn't converting IncomingMessage → Web Request before handing off to the h3 v2 handler — but I'm not deep enough in this stack to be sure that's the full picture.

    One thing worth noting from my testing: @solidjs/vite-plugin-nitro-2@0.2.0 doesn't seem to fix it on my end (I tried the pkg.pr.new build of PR #2116). Both 0.1.0 and 0.2.0 still seem to pull in h3 v1 via nitropack, and the bundled srvx inside .output/server/node_modules/.nitro/srvx@0.11.15 appears to be reached via the v1 path regardless.

    The pnpm workaround mentioned above might be working because pnpm's stricter dep resolution deduplicates h3 — that's just a guess though.

    For anyone else blocked, I ended up reverting to SolidStart v1 + Vinxi while waiting for this to settle.

  5. AshrafChitamba commented on May 27, 2026

    @AshrafChitamba

    I was facing this issue. It doesn't seem to be fixed yet with other package managers; I'm using pnpm for now.

  6. AFatNiBBa commented on Jun 17, 2026

    @AFatNiBBa

    Is there some setup of the override feature that could be used to fix this?

  7. birkskyum commented on Jul 17, 2026

    @birkskyum
    Member

    The Nitro v2 vite plugin is deprecated. Please reopen if this also happens with Nitro v3 / Vite 8 / latest SolidStart pre-release.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Start 2.xtargeting SolidStart 2.x versionsbugSomething isn't workingneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions