Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: ClientRequest.options.createConnection #19507

Open
monotter opened this issue Jun 14, 2023 · 29 comments · May be fixed by #25470
Open

node: ClientRequest.options.createConnection #19507

monotter opened this issue Jun 14, 2023 · 29 comments · May be fixed by #25470
Assignees
Labels
bug Something isn't working correctly node API Related to various "node:*" modules APIs node compat node:http Issues with `node:http` module - to be fixed with a rewrite

Comments

@monotter
Copy link

import tls from 'node:tls'
import https from 'node:https'
import net from 'node:net'

function tlsConnect(options) {
  options.path = undefined;

  if (!options.servername && options.servername !== '') {
    options.servername = net.isIP(options.host) ? '' : options.host;
  }

  return tls.connect(options);
}

const opts = {
  protocolVersion: 13,
  maxPayload: 104857600,
  skipUTF8Validation: false,
  perMessageDeflate: true,
  followRedirects: false,
  maxRedirects: 10,
  handshakeTimeout: 30000,
  createConnection: tlsConnect,
  socketPath: undefined,
  hostname: undefined,
  protocol: undefined,
  timeout: 30000,
  method: "GET",
  host: "gateway.discord.gg",
  path: "/?v=10&encoding=json",
  port: 443,
  defaultPort: 443,
  headers: {
    Connection: "Upgrade",
    Upgrade: "websocket",
    "Sec-WebSocket-Extensions": "permessage-deflate; client_max_window_bits"
  }
}

https.request(opts)

I've had an issue on DiscordJS with deno. Whenever I run this code I am getting this issue below.
Ekran Resmi 2023-06-14 21 12 16

@bartlomieju
Copy link
Member

FYI support for discord.js was added in #19412 and will be released tomorrow in v1.34.3. That said ClientReuqest.options.createConnection is still not supported and ignored entirely.

@bartlomieju bartlomieju changed the title Error: Not implemented: ClientRequest.options.createConnection node: ClientRequest.options.createConnection Jun 14, 2023
@bartlomieju bartlomieju added the bug Something isn't working correctly label Jun 14, 2023
@bartlomieju bartlomieju self-assigned this Jun 14, 2023
@RandyPen
Copy link

RandyPen commented Jul 4, 2023

I encoutered a similar bug.

Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
Warning: Not implemented: ClientRequest.options.createConnection
error: Uncaught Error: Too many subscriptions on the connection
    at new JSONRPCError (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/@open-rpc/client-js/1.8.1/build/Error.js:24:28)
    at Object.exports.convertJSONToRPCError (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/@open-rpc/client-js/1.8.1/build/Error.js:37:16)
    at TransportRequestManager.processResult (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/@open-rpc/client-js/1.8.1/build/transports/TransportRequestManager.js:91:31)
    at TransportRequestManager.resolveRes (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/@open-rpc/client-js/1.8.1/build/transports/TransportRequestManager.js:113:18)
    at TransportRequestManager.resolveResponse (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/@open-rpc/client-js/1.8.1/build/transports/TransportRequestManager.js:53:25)
    at WebSocket.<anonymous> (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/@open-rpc/client-js/1.8.1/build/transports/WebSocketTransport.js:77:47)
    at WebSocket.onMessage (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/ws/7.5.9/lib/event-target.js:132:16)
    at WebSocket.emit (ext:deno_node/_events.mjs:379:28)
    at Receiver.receiverOnMessage (file:///Users/xxx/Library/Caches/deno/npm/registry.npmjs.org/ws/7.5.9/lib/websocket.js:1068:20)
    at Receiver.emit (ext:deno_node/_stream.mjs:1852:9)

the source code is

import { JsonRpcProvider, Connection, SuiEvent } from 'npm:@mysten/sui.js';

// Construct your connection:
const connection = new Connection({
	websocket: 'wss://fullnode.testnet.sui.io',
	faucet: 'https://faucet.testnet.sui.io/gas',
});
// connect to Testnet
const provider = new JsonRpcProvider(connection);

const promptPackage = '0x86e2ab6c370fbfed0ee955158ca95ca5b465dede4a79eb3594d2959e72d3d62a';
const promptFilter = { MoveModule: { package: promptPackage, module: 'cybrosnetwork' } };
const promptSub = await provider.subscribeEvent({
    filter: promptFilter,
    onMessage(event: SuiEvent) {
      // handle subscription notification message here
      console.log(event["parsedJson"]);
    },
  });

@Mrowa96
Copy link

Mrowa96 commented Aug 10, 2023

Same for me using puppeteer

import { join } from "https://deno.land/[email protected]/path/mod.ts";
import denoDir from "https://deno.land/x/dir/mod.ts";
import puppeteer from 'npm:[email protected]';
import {install, resolveBuildId} from "npm:@puppeteer/[email protected]"

const {executablePath} = await install({
      browser: 'chrome',
      buildId: '113.0.5672.0',
      cacheDir: join(denoDir('cache'), "puppeteer")
});

const browser = await puppeteer.launch({
      headless: false,
      executablePath, 
});

const page = await browser.newPage();

await page.setContent(`<p>test</p>`, { waitUntil: 'networkidle2' });

@acrodrig
Copy link

acrodrig commented Oct 3, 2023

Is there a workaround? I am trying to use Deno with the mqtt and I get the same issue. Thanks.

@theandym
Copy link

I'm also experiencing this issue with CCXT — specifically with CCXT Pro and its connection via websockets for the watch* methods.

@uynilo9
Copy link

uynilo9 commented Oct 28, 2023

the same as me with npm:discord.js

@SoftwareAndOutsourcing
Copy link

I can reproduce this issue in #21096.

@Abdillah
Copy link

Abdillah commented Dec 1, 2023

I'm reproducing this on npm:selenium-webdriver which uses Chrome Debug Protocol (using websocket, ws package). Using the following code:

import { Builder } from 'npm:selenium-webdriver';

const builder = new Builder()
.forBrowser(Browser.CHROME)

try {
    const driver = await builder.build();
    const cdp = await driver.createCDPConnection('page');
} catch(e) {
    console.log("ERR", e)
}

@kingkong404
Copy link

kingkong404 commented Dec 4, 2023

+1 having this issue with Discord JS

@worotyns
Copy link

worotyns commented Jan 2, 2024

Same in npm:@slack/bolt

@mariusheil
Copy link

I am also using mqtt.js and while everything seems to work, the same error is thrown and it would be nice if it were fixed. Not sure of the implications when this error is thrown.

@vanvanni
Copy link

+1, Also encountering this in Discord.JS and still have to start with MQTT.

@jpagand
Copy link

jpagand commented Jan 23, 2024

I am also using mqtt.js and while everything seems to work, the same error is thrown and it would be nice if it were fixed. Not sure of the implications when this error is thrown.

For me, the websocket reconnection logic doesn't work

@bartlomieju bartlomieju removed their assignment Mar 4, 2024
@bartlomieju bartlomieju added the node API Related to various "node:*" modules APIs label Mar 4, 2024
@gardc
Copy link

gardc commented May 1, 2024

+1 having this issue with Discord JS

Same here, still an issue.

@ducan-ne
Copy link

ducan-ne commented Jun 18, 2024

Same here, this blocks me from using port checking libs, wondering any workaround for that

@Sunf3r
Copy link

Sunf3r commented Jun 27, 2024

Same in npm:baileys

@bartlomieju bartlomieju added the node:http Issues with `node:http` module - to be fixed with a rewrite label Jul 1, 2024
@maheshbansod
Copy link

Issue still exists in 1.45.2

@mariusheil
Copy link

For npm:mqtt, this is really annoying as it is the only major mqtt implementation that can be used for deno. All the other implementations are not maintained anymore. At least I was not able to find a maintained package.

@bartlomieju bartlomieju self-assigned this Jul 18, 2024
@ry ry assigned kt3k Aug 20, 2024
@kt3k kt3k assigned satyarohith and unassigned kt3k Aug 26, 2024
@bartlomieju bartlomieju removed their assignment Aug 27, 2024
@elimydlarz
Copy link

elimydlarz commented Oct 7, 2024

Also getting this error when trying to use OpenAI's new Realtime API client in my Deno project.

Broadly, it's problematic that Deno's WebSocket implementation is missing features from Node's implementation, mainly:

  • Whatever is causing this error
  • Attaching headers from clients (if I wanted to bypass this library and make my own Deno native client, I couldn't because I need to attach auth headers)

@hydrangea-sh
Copy link

The same issue is happening in with npm:shoukaku

@xxhertz
Copy link

xxhertz commented Oct 10, 2024

socket.io-client causing the same issue

@josephrocca
Copy link
Contributor

Another affected package: npm:chrome-remote-interface (DevTools debugger protocol)

@mlshv
Copy link

mlshv commented Oct 11, 2024

Same with npm:puppeteer

@bartlomieju
Copy link
Member

Thanks for comments. We'll prioritize fixing this problem.

@cobbvanth
Copy link

Thanks for comments. We'll prioritize fixing this problem.

Awesome, thank you, just encountered this and am very excited for the merge.

@RickDT
Copy link

RickDT commented Oct 12, 2024

I think this is also blocking npm:wrangler pages dev which is Cloudflare's local preview environment.

TIA for prioritizing it!

@herenickname
Copy link

herenickname commented Oct 16, 2024

node:http agents are not working because of this, we are waiting! :)

@rdbo
Copy link

rdbo commented Nov 28, 2024

I'm having issues as well connecting with a local websocket

@117
Copy link

117 commented Dec 3, 2024

npm:ws has this issue as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node API Related to various "node:*" modules APIs node compat node:http Issues with `node:http` module - to be fixed with a rewrite
Projects
None yet
Development

Successfully merging a pull request may close this issue.