Hello guys
This ticket is rather a request for an explanation of an error I do not fully understand. Do you think you could either add more context to the error or examine the following stack trace and tell me what it could be?
Error: not opened
at WebSocket.send (/var/www/videomail/production/source/node_modules/ws/lib/WebSocket.js:181:16)
at DestroyableTransform.socketWrite [as _transform] (/var/www/videomail/production/source/node_modules/websocket-stream/index.js:35:12)
at DestroyableTransform.Transform._read (/var/www/videomail/production/source/node_modules/websocket-stream/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/var/www/videomail/production/source/node_modules/websocket-stream/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/var/www/videomail/production/source/node_modules/websocket-stream/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/var/www/videomail/production/source/node_modules/websocket-stream/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (/var/www/videomail/production/source/node_modules/websocket-stream/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at writeCommand (/var/www/videomail/production/source/src/socket/items/client.js:204:16)
at makeVideos (/var/www/videomail/production/source/src/socket/commands/stop.js:35:24)
at fn (/var/www/videomail/production/source/node_modules/async/lib/async.js:641:34)
Many thanks!
Check the source code (lib/WebSocket.js line 181).
I see. Do you think we could make this error message a bit more developer-friendly? Something like that:
if (this.readyState != WebSocket.OPEN) {
var err = new Error('Socket not opened. Expected state is OPEN but current state is set to ' + this.readyState.toString());
if (typeof cb == 'function') cb(err);
else throw err;
return;
}
whereas this.readyState.toString() is just an example to print the string expression of the state instead of a number.
I think that would be nice and will definitely help developers to spot bugs in their own app code.
Well, IMHO "not opened "means that the state is not "open" :) but yes, yours would be more friendly. Note that I'm not the author at all, so don't hesitate to send a PR.
But you cannot override the toString method of the readyState attribute given that its value is a Number.
Yeah, the above was just "pseudo code".
Would love to do a PR but have other priorities right now, sorry :(
Here you go! :) @ibc
Most helpful comment
I see. Do you think we could make this error message a bit more developer-friendly? Something like that:
whereas
this.readyState.toString()is just an example to print the string expression of the state instead of a number.I think that would be nice and will definitely help developers to spot bugs in their own app code.