Friday, December 20, 2013

Re: How to handle RPC StatusCodeException

1) When the user refreshes the page (from the browser), in the timeslot, where we have sent an RPC request to a server, we can catch the following stack trace from Developer mode:

ERROR: Uncaught exception escaped

com.google.gwt.core.client.JavaScriptException: (NS_ERROR_NOT_AVAILABLE) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(569), JavaScript object(568), JavaScript object(616)]): prompt aborted by user

                at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)

                at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)

                at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)

                at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)

                at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)

                at com.google.gwt.core.client.impl.Impl.apply(Impl.java)

                at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:606)

                at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

                at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

                at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

                at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)

                at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)

                at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)

                at java.lang.Thread.run(Thread.java:744)


I have only seen this exception in Firefox so far, when refreshing the page while a Window.alert() window is open. Normally a browser should forbid reloading until the Window.alert() is closed by the user but Firefox allows you to reload the page without closing the alert.

We simply swallow the exception in our apps' UncaughtExceptionHandler by looking for the string "prompt aborted by user". I have also thought about filing a bug against GWT so that this exception is automatically swallowed by the Window class for the FireFox permutation, but haven't done so yet. By swallowing it you don't have to deal with it anymore.



 

2) We see something similar, when running our Selenium test. If our startup page contains RPC calls, the second Selenium test fails with an Unhandled alert and an alert box, containing the following text (in our Selenium setup, we refresh the url between each test case):

Error:
com.google.gwt.user.client.rpc.StatusCodeException - 0
- [Unknown.jh(Unknown Source), 
Unknown._O(Unknown Source), 
Unknown.HQ(Unknown Source), 
Unknown.Yq(Unknown Source), 
Unknown.nr(Unknown Source), 
Unknown.SZ/c.onreadystatechange<(Unknown Source), 
Unknown.Fh(Unknown Source), 
Unknown.lh(Unknown Source), 
Unknown.Hh/<(Unknown Source), 
Unknown.anonymous(Unknown Source)]

In both cases, our theory is, that after having sent the RPC, the browser is refreshed - and when we get the answer from the RPC call, we are not expecting it, and we think, that this is what causes the error.

You always get that exception when you don't have internet, hit the same origin policy or a RPC call is aborted by the user. I am not sure if I have seen this error during a page refresh but you can easily produce this error in Firefox when hitting ESC during a RPC request which cancels the RPC. Not sure if it still works the same in current FireFox versions. Haven't tested it for a while. But with FireFox ~20 it was definitely possible.

Not sure how to solve this during your Selenium testing but obviously this behavior can also occur during normal app usage so your app should have some code to handle it. For example if you see status code 0 you could retry the request 2 more times and then give up with an error message telling the user that he/she does not have internet.


Hope that helps a bit.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment