Browse Source

Handle undefined script execution result.

pull/7615/head
Igor Kulikov 4 years ago
parent
commit
25f8ff2aef
  1. 2
      msa/js-executor/api/jsExecutor.models.ts
  2. 6
      msa/js-executor/api/jsInvokeMessageProcessor.ts

2
msa/js-executor/api/jsExecutor.models.ts

@ -56,7 +56,7 @@ export interface JsCompileResponse extends TbMessage {
export interface JsInvokeResponse {
success: boolean;
result: string;
result?: string;
errorCode?: number;
errorDetails?: string;
}

6
msa/js-executor/api/jsInvokeMessageProcessor.ts

@ -175,8 +175,8 @@ export class JsInvokeMessageProcessor {
this.getOrCompileScript(scriptId, invokeRequest.scriptBody).then(
(script) => {
this.executor.executeScript(script, invokeRequest.args, invokeRequest.timeout).then(
(result) => {
if (result.length <= maxResultSize) {
(result: string | undefined) => {
if (!result || result.length <= maxResultSize) {
const invokeResponse = JsInvokeMessageProcessor.createInvokeResponse(result, true);
this.logger.debug('[%s] Sending success invoke response, scriptId: [%s]', requestId, scriptId);
this.sendResponse(requestId, responseTopic, headers, scriptId, undefined, invokeResponse);
@ -328,7 +328,7 @@ export class JsInvokeMessageProcessor {
}
}
private static createInvokeResponse(result: string, success: boolean, errorCode?: number, err?: any): JsInvokeResponse {
private static createInvokeResponse(result: string | undefined, success: boolean, errorCode?: number, err?: any): JsInvokeResponse {
return {
errorCode: errorCode,
success: success,

Loading…
Cancel
Save