This workaround will work for your specific example. It means the xe:djContentPane is not evaluated during the xe:jsonRpcService requests, so it will avoid the race condition for this example. The workaround may not work for other scenarios involving an xe:djContentPane control.
In the Application Properties, XPages tab, in the Performance section,
uncheck the check-box "Evaluate the entire page on partial refresh".
The xsp.properties file will then contain:
xsp.ajax.renderwholetree=false
Note, that applications created in Designer 8.5.2 or later will have this check-box unchecked by default,
it is only older applications created in 8.5.0 or 8.5.1 that are likely to show this behavior.
When you uncheck the option, you may have to re-test your application,
to verify that partial refresh/ partial update functionality continues to behave as expected, without runtime exceptions.
Exceptions can occur because the change means
that code outside the partial refresh area is not executed during partial refresh,
so if code in the refresh area was depending on values computed elsewhere in the XPage,
that code would have to be modified to re-compute the values within in the partial refresh area.