Skip to content

Commit

Permalink
Fix action error callback crash (appsmithorg#7377)
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu authored and mohanarpit committed Sep 13, 2021
1 parent c3acf9e commit e5e0b8e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
5 changes: 2 additions & 3 deletions app/client/src/sagas/ActionExecution/PromiseActionSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ export default function* executePromiseSaga(
responseData = e.responseData;
}
// if the catch callback is not an anonymous function, passing arguments will cause errors in execution
const catchArguments = ACTION_ANONYMOUS_FUNC_REGEX.test(trigger.catch)
? responseData
: undefined;
const matches = [...trigger.catch.matchAll(ACTION_ANONYMOUS_FUNC_REGEX)];
const catchArguments = matches.length ? responseData : undefined;

yield call(executeAppAction, {
dynamicString: trigger.catch,
Expand Down
8 changes: 8 additions & 0 deletions app/client/src/sagas/PostEvaluationSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ export function* evalErrorHandler(
});
break;
}
case EvalErrorTypes.CLONE_ERROR: {
Sentry.captureException(new Error(error.message), {
extra: {
request: error.context,
},
});
break;
}
default: {
Sentry.captureException(error);
log.debug(error);
Expand Down
1 change: 1 addition & 0 deletions app/client/src/utils/DynamicBindingUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export enum EvalErrorTypes {
BAD_UNEVAL_TREE_ERROR = "BAD_UNEVAL_TREE_ERROR",
EVAL_TRIGGER_ERROR = "EVAL_TRIGGER_ERROR",
PARSE_JS_ERROR = "PARSE_JS_ERROR",
CLONE_ERROR = "CLONE_ERROR",
}

export type EvalError = {
Expand Down
27 changes: 22 additions & 5 deletions app/client/src/workers/evaluation.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,28 @@ function messageEventListener(
const { method, requestData, requestId } = e.data;
const responseData = fn(method, requestData);
const endTime = performance.now();
ctx.postMessage({
requestId,
responseData,
timeTaken: (endTime - startTime).toFixed(2),
});
try {
ctx.postMessage({
requestId,
responseData,
timeTaken: (endTime - startTime).toFixed(2),
});
} catch (e) {
console.error(e);
ctx.postMessage({
requestId,
responseData: {
errors: [
{
type: EvalErrorTypes.CLONE_ERROR,
message: e,
context: requestData,
},
],
},
timeTaken: (endTime - startTime).toFixed(2),
});
}
};
}

Expand Down

0 comments on commit e5e0b8e

Please sign in to comment.