enumerable property causes server to abort
Closed this issue · 2 comments
On a chrome based client connecting to a nodejs sever I've started to get the following error - which causes the entire server to abort and crash.
LOG info GET /myapp/socket/info?t=1635790354878 3ms 200
LOG error Exception on "GET /myapp/socket/776/vp3on54j/websocket" in filter "sockjs_websocket":
Error: Unrecognized option: getKey
at Function.Base.validateOptions (/Users/conway/Projects/myapp/node_modules/websocket-driver/lib/websocket/driver/base.js:41:13)
at Hybi.Base (/Users/conway/Projects/myapp/node_modules/websocket-driver/lib/websocket/driver/base.js:12:8)
at new Hybi (/Users/conway/Projects/myapp/node_modules/websocket-driver/lib/websocket/driver/hybi.js:12:8)
at Function.Server.http (/Users/conway/Projects/myapp/node_modules/websocket-driver/lib/websocket/driver/server.js:105:12)
at Object.http (/Users/conway/Projects/myapp/node_modules/websocket-driver/lib/websocket/driver.js:27:24)
at new WebSocket (/Users/conway/Projects/myapp/node_modules/faye-websocket/lib/faye/websocket.js:17:25)
at App.sockjs_websocket (/Users/conway/Projects/myapp/node_modules/sockjs/lib/trans-websocket.js:25:12)
at execute_request (/Users/conway/Projects/myapp/node_modules/sockjs/lib/webjs.js:22:37)
at IncomingMessage.req.next_filter (/Users/conway/Projects/myapp/node_modules/sockjs/lib/webjs.js:100:18)
at Listener.webjs_handler (/Users/conway/Projects/myapp/node_modules/sockjs/lib/webjs.js:102:13)
Looking at the code at that point (base.js line 41)
Base.validateOptions = function(options, validKeys) {
for (var key in options) {
if (validKeys.indexOf(key) < 0)
throw new Error('Unrecognized option: ' + key);
}
};
you can see it is not checking for only local properties and for some reason options seems to now have an enumerable property called getKey
The fix is the time honoured method of adding an if (options.hasOwnProperty(key)) {
within the for loop to only check against valid properties.
Any chance this could get patched and released ?
It looks like you are referencing code in the websocket-driver
npm module? https://github.com/faye/websocket-driver-node/blob/main/lib/websocket/driver/base.js#L38-L43
Please open an issue there, if that is the source of the problem.
OK - reported there. Hopefully if they fix it then the changes will ripple through - but may need package-lock.json refresh.