Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Explanation for "Error: not opened" #394

Closed
binarykitchen opened this issue Nov 2, 2014 · 5 comments
Closed

Explanation for "Error: not opened" #394

binarykitchen opened this issue Nov 2, 2014 · 5 comments

Comments

@binarykitchen
Copy link

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?

Stack
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!

@ibc
Copy link
Contributor

ibc commented Nov 16, 2014

Check the source code (lib/WebSocket.js line 181).

@binarykitchen
Copy link
Author

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.

@ibc
Copy link
Contributor

ibc commented Nov 17, 2014

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.

@binarykitchen
Copy link
Author

Yeah, the above was just "pseudo code".

Would love to do a PR but have other priorities right now, sorry :(

@binarykitchen
Copy link
Author

Here you go! :) @ibc

@lpinca lpinca closed this as completed Jan 27, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants