-
Notifications
You must be signed in to change notification settings - Fork 568
Closed
Description
Note: for support questions, please use one of these channels: stackoverflow or slack
You want to:
- report a bug
- request a feature
Current behaviour
An error is thrown when not using Server.prototype.attach
directly or indirectly.
Steps to reproduce (if the current behaviour is a bug)
Run the following the test case
'use strict';
const eioc = require('engine.io-client');
const eio = require('engine.io');
const http = require('http');
const server = http.createServer();
const engine = new eio.Server();
engine.on('connection', (socket) => {
socket.on('message', (data) => socket.send(data));
socket.on('close', () => console.log('close'));
});
server.on('upgrade', (req, socket, head) => {
engine.handleUpgrade(req, socket, head);
});
server.on('request', (req, res) => {
engine.handleRequest(req, res);
});
server.listen(3000, () => {
const socket = eioc('http://localhost:3000');
socket.on('open', () => socket.send('foo'));
socket.on('message', (data) => console.log(data));
socket.on('close', () => console.log('close'));
});
Expected behaviour
The above example should work without throwing errors.
Setup
- OS: macOS
- browser: -
- engine.io version: 2.0.0
Other information (e.g. stacktraces, related issues, suggestions how to fix)
TypeError: Cannot read property 'handleUpgrade' of undefined
at /Users/luigi/eio-2.0/node_modules/engine.io/lib/server.js:360:12
at Server.verify (/Users/luigi/eio-2.0/node_modules/engine.io/lib/server.js:171:3)
at Server.handleUpgrade (/Users/luigi/eio-2.0/node_modules/engine.io/lib/server.js:349:8)
at Server.server.on (/Users/luigi/eio-2.0/index.js:16:10)
at emitThree (events.js:116:13)
at Server.emit (events.js:194:7)
at onParserExecuteCommon (_http_server.js:459:14)
at onParserExecute (_http_server.js:418:3)
It seems that issue has been introduces in 7e50871 as the init
method is only called when attach
is used.
Metadata
Metadata
Assignees
Labels
No labels