From 81d738d1de6e1dd8aec84660715719785ee931fc Mon Sep 17 00:00:00 2001 From: Ashit Rath Date: Mon, 15 Jul 2024 22:34:27 +0530 Subject: [PATCH] chore: Buffer first eval action to fix race condition with setup worker (#34891) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Check the issue description for the actual problem. Solution: To mitigate the race condition; instead of using `take` post setup worker an `actionChannel` is used to create a queue to detect any first eval action dispatched while the code path completes the worker setup. This queue is then picked by and the action is processed and the `actionChannel` is closed. The baseline theory of the solution is to create a queue of any first eval action dispatch throughout the lifecycle of the setup process but act only when the setup is complete The problem is not that evident in applications but in packages it's highly reproducible as there are less api fetches to start eval Fixes https://github.com/appsmithorg/appsmith/issues/34890 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 999f677e9af9c1d90201fcf124d1246ecfd79ef2 > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Fri, 12 Jul 2024 07:07:30 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Bug Fixes** - Improved reliability and performance of evaluation change listener by optimizing action handling. --- app/client/src/sagas/EvaluationsSaga.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index a81d24267f..302ec13d8a 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -646,6 +646,7 @@ function* evalAndLintingHandler( } function* evaluationChangeListenerSaga(): any { + const firstEvalActionChannel = yield actionChannel(FIRST_EVAL_REDUX_ACTIONS); // Explicitly shutdown old worker if present yield all([call(evalWorker.shutdown), call(lintWorker.shutdown)]); const [evalWorkerListenerChannel] = yield all([ @@ -669,8 +670,9 @@ function* evaluationChangeListenerSaga(): any { yield spawn(handleEvalWorkerRequestSaga, evalWorkerListenerChannel); const initAction: EvaluationReduxAction = yield take( - FIRST_EVAL_REDUX_ACTIONS, + firstEvalActionChannel, ); + firstEvalActionChannel.close(); // Wait for widget config build to complete before starting evaluation only if the current editor is not a workflow const isCurrentEditorWorkflowType = yield select(