Skip to content

@sveltejs/adapter-node error when used as handler with native node http package #8888

@CaptainCodeman

Description

@CaptainCodeman

Describe the bug

Using @sveltejs/adapter-node v1.1.6 fails with a cryptic error message when trying to use the handler with the inbuilt node http package, but works with express.

Reproduction

This fails:

import http from 'http'
import { handler } from './build/handler.js'

http.createServer(handler).listen(3000)

This works:

import express from 'express'
import { handler } from './build/handler.js'

express().use(handler).listen(3000)

Logs

Error: Not found: /
    at resolve (file:///project/build/server/index.js:3178:18)
    at resolve (file:///project/build/server/index.js:3045:34)
    at #options.hooks.handle (file:///project/build/server/index.js:3223:59)
    at respond (file:///project/build/server/index.js:3043:43)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Array.ssr (file:///project/build/handler.js:21839:3)

System Info

System:
    OS: macOS 13.2
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 2.70 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.10.0 - ~/Library/pnpm/node
    npm: 8.19.2 - ~/Library/pnpm/npm
  Browsers:
    Brave Browser: 106.1.44.112
    Chrome: 109.0.5414.119
    Chrome Canary: 112.0.5579.0
    Firefox: 109.0
    Safari: 16.3
    Safari Technology Preview: 16.4
  npmPackages:
    @sveltejs/adapter-node: 1.1.5 => 1.1.6 
    @sveltejs/kit: ^1.3.10 => 1.3.10 
    svelte: ^3.55.1 => 3.55.1 
    vite: ^4.1.1 => 4.1.1

Severity

serious, but I can work around it

Additional Information

Rolling back to @sveltejs/adapter-node v1.1.5 works.

I don't want to add express as an extra dependency and the real server script includes other things (static file caching, proxy and http compression)

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