Handle undefined script execution result.
This commit is contained in:
parent
51ec17d9d1
commit
25f8ff2aef
@ -56,7 +56,7 @@ export interface JsCompileResponse extends TbMessage {
|
|||||||
|
|
||||||
export interface JsInvokeResponse {
|
export interface JsInvokeResponse {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
result: string;
|
result?: string;
|
||||||
errorCode?: number;
|
errorCode?: number;
|
||||||
errorDetails?: string;
|
errorDetails?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -175,8 +175,8 @@ export class JsInvokeMessageProcessor {
|
|||||||
this.getOrCompileScript(scriptId, invokeRequest.scriptBody).then(
|
this.getOrCompileScript(scriptId, invokeRequest.scriptBody).then(
|
||||||
(script) => {
|
(script) => {
|
||||||
this.executor.executeScript(script, invokeRequest.args, invokeRequest.timeout).then(
|
this.executor.executeScript(script, invokeRequest.args, invokeRequest.timeout).then(
|
||||||
(result) => {
|
(result: string | undefined) => {
|
||||||
if (result.length <= maxResultSize) {
|
if (!result || result.length <= maxResultSize) {
|
||||||
const invokeResponse = JsInvokeMessageProcessor.createInvokeResponse(result, true);
|
const invokeResponse = JsInvokeMessageProcessor.createInvokeResponse(result, true);
|
||||||
this.logger.debug('[%s] Sending success invoke response, scriptId: [%s]', requestId, scriptId);
|
this.logger.debug('[%s] Sending success invoke response, scriptId: [%s]', requestId, scriptId);
|
||||||
this.sendResponse(requestId, responseTopic, headers, scriptId, undefined, invokeResponse);
|
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 {
|
return {
|
||||||
errorCode: errorCode,
|
errorCode: errorCode,
|
||||||
success: success,
|
success: success,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user