Closed ghost closed 13 years ago
In general: the server should never throw because of behavior implemented on the client-side. This is a bug.
The fun is that the behavior isn't implemented by the client ;) The same result will be if you call non-existent-in-the-context function even if client has been connected.
So I hardly consider this a bug -- buggy is the way the server is used. The server must ensure client is connected before it calls anything from the shared context.
@dvv, currently, if a client manually removes this code the server may throw an error while if the client does not do this the server will not.
I don't get, sorry. Mind to drop a couple of lines of code for server and client side? TIA
@dvv sure, although this only happens if there is not a single client with such function.
server:
everyone.on('connect', function() {
everyone.now.iDoNotExist();
});
client:
//just setup now and do not add any now functions
Ah, I see now. This is the "magic" of everyone
...
Here is the current behavior in the case that the client decides to change the code to remove/overwrite methods
everyone.now
so everyone.now.someFunction()
will always work if there has ever been a user that had the function, even if that user is disconnected or has change the methods client-sidethis.now.someFunction()
on every client, and one of the client has removed their version of that function, an error will be thrown, however this will not crash the server. That client for which it did crash, and only that client, will be disconnected.To address the original poster, although a stack trace is printed, the method he is seeing does not crash the server as NowJS catches all uncaught exceptions. Thus it is rather harmless.
The only thing you can really do is to, instead of printing the stack trace, make the error look prettier because it is impossible to make some kind of catch all method for any possible method you might want to call that doesn't exist yet
Closing due to no real solution
Please ignore above message, that commit didn't actually have anything to do with this issue.
function created on the client; Server calls function with some data;
Client has yet to connect and I call the function (Bang!)
Object #
yep could catch with a try; however should this not just be transparent; if I call a function that does not exist on the everyone.now object then it should not throw an error?