-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
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:
- Save the
Event: 'upgrade'example in a file - 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:
- Clone the standard lib:
git clone https://github.com/denoland/deno_std - Change the import statement at the top of the script to
import * as http from '/$PATH_TO/deno_std/node/http.ts' - Now you can alter the stdlib code
- The
httpmodule is atnode/http.ts