Add handling of failed remote js responses. Do not block script due to timeout message because of queue connectivity
This commit is contained in:
		
							parent
							
								
									04d962c18c
								
							
						
					
					
						commit
						82f9eed985
					
				@ -192,14 +192,33 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService {
 | 
			
		||||
        Futures.addCallback(future, new FutureCallback<TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onSuccess(@Nullable TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse> result) {
 | 
			
		||||
                queueInvokeMsgs.incrementAndGet();
 | 
			
		||||
                if (result == null) {
 | 
			
		||||
                    queueInvokeMsgs.incrementAndGet();
 | 
			
		||||
                } else {
 | 
			
		||||
                    JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse();
 | 
			
		||||
                    if (invokeResponse.getSuccess()) {
 | 
			
		||||
                        queueInvokeMsgs.incrementAndGet();
 | 
			
		||||
                    } else {
 | 
			
		||||
                        JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode();
 | 
			
		||||
                        final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails());
 | 
			
		||||
                        onScriptExecutionError(scriptId, e, scriptBody);
 | 
			
		||||
                        if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) {
 | 
			
		||||
                            queueTimeoutMsgs.incrementAndGet();
 | 
			
		||||
                            queueFailedMsgs.incrementAndGet();
 | 
			
		||||
                        } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)
 | 
			
		||||
                                || JsInvokeProtos.JsInvokeErrorCode.RUNTIME_ERROR.equals(errorCode)) {
 | 
			
		||||
                            queueFailedMsgs.incrementAndGet();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onFailure(Throwable t) {
 | 
			
		||||
                onScriptExecutionError(scriptId, t, scriptBody);
 | 
			
		||||
                if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) {
 | 
			
		||||
                    queueTimeoutMsgs.incrementAndGet();
 | 
			
		||||
                } else {
 | 
			
		||||
                    onScriptExecutionError(scriptId, t, scriptBody);
 | 
			
		||||
                }
 | 
			
		||||
                queueFailedMsgs.incrementAndGet();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user