Skip to content

null is not an object (evaluating 'http') #18869

Open
@garage44

Description

@garage44

What version of Bun is running?

1.2.8

What platform is your computer?

Linux 6.5.0-valve23-1-neptune-65-g385b5e207ae2 x86_64 unknown

What steps can reproduce the bug?

I made a websocket server with WS. Connecting a client produces the following error from 1.2.6 - 1.2.8:

471 | function abortHandshake(response, code, message, headers) {
472 |   message = message || http.STATUS_CODES[code], headers = {
473 |     Connection: "close",
474 |     "Content-Type": "text/html",
475 |     "Content-Length": @Buffer.byteLength(message),
476 |   }, response.writeHead(code, headers), response.write(message), response.end();
                   ^
TypeError: null is not an object (evaluating 'http')
      at abortHandshake (ws:476:14)
      at completeUpgrade (ws:809:21)
      at handleUpgrade (ws:859:25)
      at <anonymous> (ws:728:27)
      at emit (node:events:95:22)
      at onNodeHTTPRequest (node:http:563:24)
[2025-04-08T17:33:31.838Z] [INFO] GET /favicon.ico 200 3ms
[2025-04-08T17:33:31.855Z] [INFO] GET /api/context 200 2ms

Maybe related to the node:http rewrite?

What is the expected behavior?

Websocket client is connected to the WS server without exception

What do you see instead?

The connection process hangs, after which the exception is produced after a short while.

Additional information

I did a quick try to port the application to Bun.serve. Maybe I'll retry this later when I got it stable with WS :-)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions