Skip to content

RC: Build nitro node-server exception with initial request and headers #5263

@kevinehosford

Description

@kevinehosford

Which project does this relate to?

Start

Describe the bug

Hi! I tried building using the nitro compatibility plugin and using node-server to mimic the setup I was using before upgrading to the RC and am seeing:

  • request only has a relative url and in Start this throws an exception with new URL(req.url).origin
  • request.header.get is undefined, it looks like this is the node incoming request (also unhandled)
DEBUG: Request object type: object
DEBUG: Request constructor: IncomingMessage
DEBUG: Request headers type: object
DEBUG: Headers.get exists: undefined
TypeError: Invalid URL
    at new URL (node:internal/url:818:25)
    ... 8 lines matching cause stack trace ...
    at Object.handler (file:///Users/khosford/source/start-request/request-bug/.output/server/index.mjs:1558:31) {
  cause: TypeError: Invalid URL
      at new URL (node:internal/url:818:25)
      at startRequestResolver (file:///Users/khosford/source/start-request/request-bug/.output/server/chunks/virtual/entry.mjs:1059:17)
      at file:///Users/khosford/source/start-request/request-bug/.output/server/chunks/virtual/entry.mjs:646:13
      at AsyncLocalStorage.run (node:internal/async_local_storage/async_hooks:91:14)
      at Object.fetch (file:///Users/khosford/source/start-request/request-bug/.output/server/chunks/virtual/entry.mjs:644:35)
      at fetch (file:///Users/khosford/source/start-request/request-bug/.output/server/chunks/virtual/entry.mjs:1371:21)
      at Object.handler (file:///Users/khosford/source/start-request/request-bug/.output/server/chunks/virtual/entry.mjs:378:20)
      at Object.handler (file:///Users/khosford/source/start-request/request-bug/.output/server/index.mjs:1487:24)
      at Object.handler (file:///Users/khosford/source/start-request/request-bug/.output/server/index.mjs:1797:34)
      at Object.handler (file:///Users/khosford/source/start-request/request-bug/.output/server/index.mjs:1558:31) {
    code: 'ERR_INVALID_URL',
    input: '/.well-known/appspecific/com.chrome.devtools.json'
  },
  status: 500,
  statusText: undefined,
  headers: undefined,
  data: undefined,
  body: undefined,
  unhandled: true
}

Your Example Website or App

https://github.com/kevinehosford/start-incoming-request

Steps to Reproduce the Bug or Issue

  1. git clone https://github.com/kevinehosford/start-incoming-request
  2. (p)npm i, build, start
  3. visit localhost:3000 and see
{"status":500,"unhandled":true,"message":"HTTPError"}

Expected behavior

I expected the page would load and no exception thrown

Screenshots or Videos

No response

Platform

    "@tanstack/nitro-v2-vite-plugin": "^1.132.0",
    "@tanstack/react-router": "^1.132.0",
    "@tanstack/react-router-ssr-query": "^1.131.7",
    "@tanstack/react-start": "^1.132.0",
    "@tanstack/router-plugin": "^1.132.0",
    "nitropack": "^2.12.6",
    "vite": "^7.1.7",

Additional context

The upgrade was smooth! Just wondering what I can do about this. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions