Skip to content

[Node Compat] http.ClientRequest does not emit upgrade event (or is buggy) #17847

@d4h0

Description

@d4h0

Hi,

I tried to figure out how to solve #16899, and discovered that the HTTP client of the Node Compat layer does not emit the upgrade event.

This means, that no NPM package that contains a WebSocket client will work properly.

I tried really hard to figure out what's going on, and how to fix it, but I'm not really a Typescript programmer, and the code is hard to follow for me.

It seems, the HTTP client just does not implement the event (it is implemented for the server, however).

The Event: 'upgrade' example in the docs of the Node.js http module is a good way to reproduce the issue.

You can run it, as follows:

  1. Save the Event: 'upgrade' example in a file
  2. Change the import statement at the top to import * as http from "https://deno.land/std@0.170.0/node/http.ts";

If you now execute the script, it will just hang. With Node.js, it prints the expected text to the terminal.

Also (because it took me bit to figure this out), here is the easiest way to debug the issue, I've found:

  1. Clone the standard lib: git clone https://github.com/denoland/deno_std
  2. Change the import statement at the top of the script to import * as http from '/$PATH_TO/deno_std/node/http.ts'
  3. Now you can alter the stdlib code
  4. The http module is at node/http.ts

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