Returning 500 Error on UI.init bug with FireFox

I had some bad server side code that was generating a 500 error with some response text due to an exception being raised during UI.init. I found that FireFox would properly display the error page but would be stuck with a “Connecting…” status and a spinning load indicator.

I’m not an expert here, but I think the problem is in vaadinBootstrap.js around line 122. If a 500 error comes back from the browserDetails POST, document.write() is used to output the response. The problem is that the async XHR request would come back after the original document has been written and according to Mozilla’s documentation, document.write will implicitly call document.open in this case which renders a new page. It looks like document.close is then never called and the page is left with a spinning loading indicator.

The behavior looks correct on Chrome but that might just be because they handle document.write on a complete/closed document differently.

It seems like it might be safer to append/insert the response into an embedded iframe or something in the case of a 500 error on bootstrap rather than trying to write the content during an XHR response. The error response would most likely be a complete HTML document so I think you’d have to use an iframe rather than just replacing a DIV or something because you’d end up with nested HTML/BODY tags.

You should be able to reproduce this but just throwing an exception in the UI.init method of a simple application. This is on FireFox 16.0.2 and Vaadin 7 beta8.

On a related note, is there a better way to handle exceptions during init than just relying on error-page in web.xml? It looks like the Terminal.ErroHandler isn’t used at this point because the UI isn’t fully constructed.

-mike