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

NodeJS Crashed #43057

Open
Deekit0904 opened this issue May 11, 2022 · 4 comments
Open

NodeJS Crashed #43057

Deekit0904 opened this issue May 11, 2022 · 4 comments
Labels
net Issues and PRs related to the net subsystem.

Comments

@Deekit0904
Copy link

Deekit0904 commented May 11, 2022

Version

v16.15.0

Platform

Linux localhost 4.15.0-123-generic #126-Ubuntu SMP Wed Oct 21 09:40:11 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Error: 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

    at new NodeError (node:internal/errors:372:5)
    at assert (node:internal/assert:14:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1151:3)
[ERROR] 12:00:06 Error: 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

How often does it reproduce? Is there a required condition?

everytime when nodejs is reconnecting

What is the expected behavior?

its should work and not crash

What do you see instead?

Error: 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

    at new NodeError (node:internal/errors:372:5)
    at assert (node:internal/assert:14:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1151:3)
[ERROR] 12:00:06 Error: 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

Additional information

Code

import { Socket } from "net";

const Client = new Socket();

Client.setTimeout(2500);
Client.setKeepAlive(true);

const ConnectOpts = {
    host:"127.0.0.1",
    port:9988
}

var ConnectIntervel = setInterval(() => {
    Client.connect(ConnectOpts);
},10000);

Client.on("connect", async () => {

    clearInterval(ConnectIntervel);

    console.log("Connected!")

    Client.write(JSON.stringify({
        "never":true,
        "gonna":true,
        "give":true,
        "you":true,
        "up":true
    }))

})

Client.on("data", async (BufferData) => {

})

Client.on('close', function(e) {

    Client.destroy();

    ConnectIntervel = setInterval(() => {
        Client.connect(ConnectOpts);
    },5000);

});

Client.on('error', (err) => {

    Client.destroy();

    ConnectIntervel = setInterval(() => {
        Client.connect(ConnectOpts);
    },5000);
    
})
@himself65 himself65 added the net Issues and PRs related to the net subsystem. label May 11, 2022
@tniessen
Copy link
Member

What's the setup here? Is there a TCP server listening on port 9988? What does "reconnecting" mean in this case? Does the server close the connection?

The code looks like it doesn't clear intervals when the connection is refused or destroyed.

@Deekit0904
Copy link
Author

Yes, I have open the tcp server on 9988 port and im trying to make the reconnecting system when the tcp server is dying

@kgno53c6w0aqlq4qeeo
Copy link

Could you please provide an example to the server to which you are connecting so that we can properly reproduce the issue?

@theanarkh
Copy link
Contributor

theanarkh commented Jul 27, 2022

I think it is triggered by this.
image

this code as follows can reproduce the issue.

const net= require('net');
net.createServer((socket) => {
  socket.destroy();
}).listen(9988);
const Client = new net.Socket();

Client.setTimeout(2500);
Client.setKeepAlive(true);

const ConnectOpts = {
    host:"127.0.0.1",
    port:9988
}

var ConnectIntervel = setInterval(() => {
    Client.connect(ConnectOpts);
},10000);

Client.on("connect", async () => {

    clearInterval(ConnectIntervel);

    console.log("Connected!")

    Client.write(JSON.stringify({
        "never":true,
        "gonna":true,
        "give":true,
        "you":true,
        "up":true
    }))

})

Client.on("data", async (BufferData) => {

})

Client.on('close', function(e) {

    Client.destroy();

    ConnectIntervel = setInterval(() => {
        Client.connect(ConnectOpts);
    },5000);

});

Client.on('error', (err) => {
    // commenting out this seems ok.
    Client.destroy();

    ConnectIntervel = setInterval(() => {
        Client.connect(ConnectOpts);
    },5000);
    
})

using connect by this way is a little strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants