Skip to content

node 8.12 net,http module emit connection bug. TypeError: ParserIncomingMessage is not a constructor . #22857

@whtiehack

Description

@whtiehack
  • Version: v8.12.0
  • Platform: linux ,windows
  • Subsystem:

Here is the code that can be reproduced:

const http = require('http');
const net = require('net');


const httpserver = http.createServer((req,res)=>{
    console.log('~~ http request');
    res.end('aaa');
})

httpserver.on('connection',(socket)=>{
    console.log('httpsever connection');
})

const netserver = net.createServer((socket)=>{
    console.log('netserver connection');
    httpserver.emit('connection',socket);
    // This listener is not important.
    socket.once('data',(data)=>{
        console.log('netserver data',data.toString());
        // This line of code is not important.
        socket.emit('data',data);
    });
}).listen(30332);

The same code run in v10.9.0 and v8.10.0 has been tested without issue.

This is a bug ,because of http_event_connection.

Note: This event can also be explicitly emitted by users to inject connections into the HTTP server. In that case, any Duplex stream can be passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions