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

PSA: If you're on node 20.0.0 and above, and want to use this library with client.configuration.connection.secure === true, use the argument --no-network-family-autoselection #13

Closed
brian6932 opened this issue May 24, 2023 · 22 comments · Fixed by nodejs/node#48464

Comments

@brian6932
Copy link

brian6932 commented May 24, 2023

Connecting over ws is unaffected
This is relatively rare now, but eventually, you'll get the following error:

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^
NotSpecified: (:) [], RemoteException
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
NotSpecified: (:) [], RemoteException
    at new NodeError (node:internal/errors:399:5)
    at assert (node:internal/assert:14:11)
    at internalConnectMultiple (node:net:1107:3)
    at Timeout.internalConnectMultipleTimeout (node:net:1638:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'ERR_INTERNAL_ASSERTION'
}
NotSpecified: (:) [], RemoteException
Node.js v20.2.0
@KararTY KararTY pinned this issue May 24, 2023
@brian6932
Copy link
Author

brian6932 commented Jun 11, 2023

Ok, I've looked into this issue a bit more, and it seems to only occur when

client.configuration.connection.secure === true && client.configuration.connection.method === `tcp`

If you make a very smol connection to tmi over tcp:

import { connect } from 'net'

const xd = connect(6667, `irc.chat.twitch.tv`, () => console.log(`connected`))

xd
	.setEncoding(`utf8`)
	.setNoDelay()
	.on(`connect`, () => xd.write(`nick justinfan123\njoin #tmiloadtesting2\n`))
	.on(`data`, _ => console.log(_))

It doesn't exhibit the issue either

Oddly enough, doing the same thing securely is working fine for me

import { TLSSocket } from 'tls'

const xd = new TLSSocket()
	.connect(6697, `irc.chat.twitch.tv`, () => console.log(`connected`))

xd
	.setEncoding(`utf8`)
	.setNoDelay()
	.on(`connect`, () => xd.write(`nick justinfan123\njoin #tmiloadtesting2\n`))
	.on(`data`, _ => console.log(_))

@tniessen
Copy link

@brian6932 To clarify, does 20.3.0 still result in the same ERR_INTERNAL_ASSERTION error, or in a different error? Could you post the stack trace (including the Node.js version at the bottom) for Node.js 20.3.0, please?

@brian6932
Copy link
Author

yes

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^
NotSpecified: (:) [], RemoteException
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
NotSpecified: (:) [], RemoteException
    at new NodeError (node:internal/errors:405:5)
    at assert (node:internal/assert:14:11)
    at internalConnectMultiple (node:net:1106:3)
    at Timeout.internalConnectMultipleTimeout (node:net:1644:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'ERR_INTERNAL_ASSERTION'
}
NotSpecified: (:) [], RemoteException
Node.js v20.3.0

@ShogunPanda
Copy link

@brian6932 I cannot reproduce this on Node.js 20.3.0.
Can you please post the result of dig irc.chat.twitch.tv here?

@brian6932
Copy link
Author


; <<>> DiG 9.16.41 <<>> irc.chat.twitch.tv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57154
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;irc.chat.twitch.tv.		IN	A

;; ANSWER SECTION:
irc.chat.twitch.tv.	148	IN	A	44.227.173.36
irc.chat.twitch.tv.	148	IN	A	34.212.92.60
irc.chat.twitch.tv.	148	IN	A	44.237.40.50

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jun 13 10:09:54 Eastern Daylight Time 2023
;; MSG SIZE  rcvd: 138

@ShogunPanda
Copy link

Ok, another question: can you please provide the entire file (or a meaningful repro) that you're trying to execute?

@brian6932
Copy link
Author

@ShogunPanda https://github.com/pajlada/brian-test-repro You can use this

Ok, I've looked into this issue a bit more, and it seems to only occur when

client.configuration.connection.secure === true && client.configuration.connection.method === `tcp`

As explained here, if secure is true (default), and tcp is the method (default), it will produce the error

@pajlada
Copy link

pajlada commented Jun 13, 2023

A more minimal example

// index.mjs
import { Socket } from "net";
import { TLSSocket } from "tls";

const port = 6697;
const host = "irc.chat.twitch.tv";

const backingSocket = new Socket();
const stream = new TLSSocket(backingSocket);

backingSocket.connect(port, host);
stream.connect(port, host);

then node index.mjs - no library dependencies needed

Host and port can be changed too and it still happens. I tested with port set to 443 and host set to httpbin.org

And confirmed it works with node --no-network-family-autoselection index.mjs

@ShogunPanda
Copy link

Hello!
I was able to reproduce this and I have a PR coming soon for node. It will probably be included in 20.4.0 and 18.17.0.

@ShogunPanda
Copy link

Hello. The fix for this is in the PR above.
I'll let you know once it lands so you can try a nightly build to see if it solves your issue.

nodejs-github-bot pushed a commit to nodejs/node that referenced this issue Jun 27, 2023
PR-URL: #48464
Fixes: npm/cli#6409
Fixes: KararTY/dank-twitch-irc#13
Fixes: #47644
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
RafaelGSS pushed a commit to nodejs/node that referenced this issue Jul 3, 2023
PR-URL: #48464
Fixes: npm/cli#6409
Fixes: KararTY/dank-twitch-irc#13
Fixes: #47644
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
@brian6932
Copy link
Author

brian6932 commented Jul 18, 2023

Seems fixed in 20.4.0

Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
PR-URL: nodejs#48464
Fixes: npm/cli#6409
Fixes: KararTY/dank-twitch-irc#13
Fixes: nodejs#47644
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
PR-URL: nodejs#48464
Fixes: npm/cli#6409
Fixes: KararTY/dank-twitch-irc#13
Fixes: nodejs#47644
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
@brian6932
Copy link
Author

brian6932 commented Oct 24, 2023

@ShogunPanda I have once again received this error. My internet connection at the moment is pretty messed up, so things are timing out, and I suspect that this error is actually taking the place of a socket timeout error.

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^
NotSpecified: (:) [], RemoteException
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
NotSpecified: (:) [], RemoteException
    at assert (node:internal/assert:14:11)
    at internalConnectMultiple (node:net:1118:3)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'ERR_INTERNAL_ASSERTION'
}
❯ node --version
v21.1.0

@ShogunPanda
Copy link

@brian6932 Were you connecting via TLS or just plain socket?

@ShogunPanda
Copy link

@brian6932 Were you using TLS?

@brian6932
Copy link
Author

brian6932 commented Oct 27, 2023

I was using a WebSocket over TLS @ShogunPanda

Configuration

client.configuration.connection.secure === true && client.configuration.connection.type === `websocket`

@ShogunPanda
Copy link

ShogunPanda commented Oct 27, 2023

Amazing, I have a lead then. I'll try to see what I can do. Thanks sir!

@brian6932
Copy link
Author

brian6932 commented Nov 8, 2023

I have received this multiple times today, and can't blame my internet this time around

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^
NotSpecified: (:) [], RemoteException
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
NotSpecified: (:) [], RemoteException
    at assert (node:internal/assert:14:11)
    at internalConnectMultiple (node:net:1118:3)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'ERR_INTERNAL_ASSERTION'
}
NotSpecified: (:) [], RemoteException
Node.js v21.1.0

@ShogunPanda
Copy link

@brian6932 which hosts were you connecting to? How are they resolved from the source host (in other words, can you please post the results of a DNS query from the source host?)

I don't need them to be real data, but I just need to understand the DNS configuration.

@brian6932
Copy link
Author

@ShogunPanda like a dig?

❯ dig irc-ws.chat.twitch.tv

; <<>> DiG 9.16.44 <<>> irc-ws.chat.twitch.tv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11876
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;irc-ws.chat.twitch.tv.         IN      A

;; ANSWER SECTION:
irc-ws.chat.twitch.tv.  178     IN      A       54.149.99.139
irc-ws.chat.twitch.tv.  178     IN      A       35.81.35.127
irc-ws.chat.twitch.tv.  178     IN      A       54.68.6.240
irc-ws.chat.twitch.tv.  178     IN      A       52.34.153.17
irc-ws.chat.twitch.tv.  178     IN      A       54.213.60.189
irc-ws.chat.twitch.tv.  178     IN      A       54.213.129.174
irc-ws.chat.twitch.tv.  178     IN      A       52.25.250.105
irc-ws.chat.twitch.tv.  178     IN      A       54.200.131.254

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Nov 11 14:19:52 Eastern Standard Time 2023
;; MSG SIZE  rcvd: 346

@ShogunPanda
Copy link

Yes, exactly. Thanks, I'll look it up!

@brian6932
Copy link
Author

brian6932 commented Dec 13, 2023

@ShogunPanda Looks like I've gotten it with

client.configuration.connection.secure === true && client.configuration.connection.type === `tcp`

as well this time.
stack

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^
NotSpecified: (:) [], RemoteException
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
NotSpecified: (:) [], RemoteException
    at assert (node:internal/assert:14:11)
    at internalConnectMultiple (node:net:1118:3)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'ERR_INTERNAL_ASSERTION'
}
NotSpecified: (:) [], RemoteException
Node.js v21.4.0

So I'll reopen this issue, but make it more general, and say that it's pretty rare. dig for tcp instead of ws.

❯ dig irc.chat.twitch.tv

; <<>> DiG 9.16.45 <<>> irc.chat.twitch.tv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58093
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;irc.chat.twitch.tv.            IN      A

;; ANSWER SECTION:
irc.chat.twitch.tv.     300     IN      A       44.227.173.36
irc.chat.twitch.tv.     300     IN      A       34.212.92.60
irc.chat.twitch.tv.     300     IN      A       44.237.40.50

;; Query time: 14 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Dec 13 10:45:23 Eastern Standard Time 2023
;; MSG SIZE  rcvd: 149

@brian6932 brian6932 reopened this Dec 13, 2023
@brian6932 brian6932 changed the title PSA: If you're on node 20.0.0 and above, and want to use this library over tcp, use the argument --no-network-family-autoselection PSA: If you're on node 20.0.0 and above, and want to use this library with client.configuration.connection.secure === true, use the argument --no-network-family-autoselection Dec 13, 2023
@ShogunPanda
Copy link

Thanks!
In the meanwhile I created nodejs/node#51045 which should finally fix this issue once for all.
I'll keep you posted on this!

@KararTY KararTY unpinned this issue May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants