franciscop / server

:desktop_computer: Simple and powerful server for Node.js
https://serverjs.io/
MIT License
3.56k stars 173 forks source link

throw new TypeError('argument res is required') #122

Closed fazelit closed 4 years ago

fazelit commented 4 years ago
const server = require('server');
const { get,socket} = server.router;

server([
    socket('connect', ctx=>{
        console.log(ctx);
    }),
]);
///////////// Response
C:\Program Files\nodejs\node.exe" "E:\Server_js\index.js"
E:\Server_js\node_modules\server\node_modules\on-headers\index.js:58
    throw new TypeError('argument res is required')
    ^

TypeError: argument res is required
    at onHeaders (E:\Server_js\node_modules\server\node_modules\on-headers\index.js:58:11)
    at session (E:\Server_js\node_modules\server\node_modules\express-session\index.js:220:5)
    at Array.<anonymous> (E:\Server_js\node_modules\server\plugins\session\index.js:44:7)
    at run (E:\Server_js\node_modules\server\node_modules\socket.io\lib\namespace.js:124:11)
    at Namespace.run (E:\Server_js\node_modules\server\node_modules\socket.io\lib\namespace.js:136:3)
    at Namespace.add (E:\Server_js\node_modules\server\node_modules\socket.io\lib\namespace.js:164:8)
    at Client.doConnect (E:\Server_js\node_modules\server\node_modules\socket.io\lib\client.js:97:20)
    at Client.connect (E:\Server_js\node_modules\server\node_modules\socket.io\lib\client.js:66:17)
    at Server.onconnection (E:\Server_js\node_modules\server\node_modules\socket.io\lib\index.js:435:10)
    at Server.emit (events.js:198:13)

Process finished with exit code 1
franciscop commented 4 years ago

Thanks for the bug report! I'll review it this weekend.

franciscop commented 4 years ago

Hi @fazelit , I cannot seem to reproduce this, but digging through the web it seems like this is a problem with missing request/res in socket.io so I just added that code which hopefully fixes it. Could you please try installing server@1.0.21? Feel free to reopen/open a new issue if it still fails :)

npm install server@1.0.21