Skip to content

TypeError: Cannot read property 'headers' of null at Server.socket.on (***/node_modules/webpack-dev-server/lib/servers/SockJSServer.js:68:32) #2199

Description

@wood1986
  • Operating System: Windows 10
  • Node Version: 12.8.1
  • NPM Version: 6.10.3
  • webpack Version: 4.39.2
  • webpack-dev-server Version: since 3.5.0
  • Browser: Chrome 76
  • This is a bug
  • This is a modification request

Expected Behavior

connection should not be null

Actual Behavior

TypeError: Cannot read property 'headers' of null at Server.socket.on (***/node_modules/webpack-dev-server/lib/servers/SockJSServer.js:68:32)

For Bugs; How can we reproduce the behavior?

This bug is difficult to reproduce. It happens occasionally.

onConnection(f) {
this.socket.on('connection', (connection) => {
f(connection, connection.headers);
});
}

line 67 should become

if (connection) {
  f(connection, connection.headers)
}

For Features; What is the motivation and/or use-case for the feature?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions