org.eclipse.rap
org.eclipse.rap copied to clipboard
Handling network connection error with SeverPush active
I suppose that not all exceptions are handled when using 'Request_sendWithFetch' , I found problems when 'ServerPush' is active, sometimes retry is working and sometimes no.
I have modified "Request_sendWithFetch" adding try .. catch inside entire function and inside every 'then' and it seems to work fine.
This is, for example, an uncaught error:

Can you tell some simple steps to reproduce the issue?
What action did you perform in order to provoke ERR_CONNECTION_RESET error?
BTW... which RAP version is used for your testing?
I'm using 3.24.0-M1 version
For testing I do:
- start a RAP application on my pc (windows 10)
- start a virtual machine with "Oracle VM VirtualBox" (windows 10)
- from virtual machine open Edge (or Chrome or Firefox) browser and point to host machine
- while application is running and browser is open, disable / enable virtual machine network card
reply this action many times and each time keep network disabled for few time or long time
while the network is disabled try both without doing anything on the browser and by performing activities on the browser (making the error message appear immediately)
I have done some tests, with PushSession active or not, and watching the error on the browser console I see the error is not always the same, the most commons are: net::ERR_ADDRESS_UNREACHABLE net::ERR_INTERNET_DISCONNECTED net::ERR_CONNECTION_RESET
and sometimes also the error above.
To do a better test, I also have increase 'ServerPush.js' retry time to prevent error message box from popping up too soon (by the way I think ServerPush should be do a continuos call without break with message if user do nothing while network is down)
Here the modified code in 'ServerPush.js' '_handleError'
if( this._retryCount < 1000 ) {
this._retryCount++;
var delay = (this._retryCount <= 5) ? 1000 : 3000;
rwt.client.Timer.once( this.sendServerPushRequest, this, delay );
} else {
this._handleConnectionError();
}
Could you try tomorrow with the RAP nightly build. I fixed the other two issues reported by you and I think that they are related.
In "Request.js" method "_sendWithFetch" there is a ".catch" only in the first ".then" command
Should be added ".catch" after every ".then" to prevent uncaught errors
I don't think this is needed. The outer ".catch" should catch all the errors thrown internally by "fetch" and ".then". More over the second Promise is for getting the response text which should never throw.