fix: 503 error fixed when navigating to homepage (#21971)

TL;DR 503 error fixed when navigating to homepage while the editor is
loading.

- `RESET_EDITOR_REQUEST` is an action that removes `currentApplication`
from the `applicationsReducer`.
- When starting the editor, appEngine saga has an action `completeChore`
which reads the `currentApplication` object.
- Now, when we go back to homepage (while the editor is still
initializing)
- `RESET_EDITOR_REQUEST` is dispatched (so `currentApplication` is
cleared)
- the appEngine still runs in the background and tries to read
`currentApplication` throwing an error.

Now we make sure appEngine is cancelled whenever `RESET_EDITOR_REQUEST`
is triggered.

A follow up task to investigate how errors are thrown in app editor
saga: #21972

Fixes #21915


## Media
Before:
https://www.loom.com/share/eae1eeeec04f4b35a9d3be6ea8177b0a

After:
https://www.loom.com/share/09c328f81d8344569c0ff0b7a3d97713
This commit is contained in:
Anand Srinivasan 2023-04-14 08:19:43 +05:30 committed by GitHub
parent b080930b71
commit 5e936e267c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,10 +148,22 @@ function* updateURLSaga(action: ReduxURLChangeAction) {
});
}
function* appEngineSaga(action: ReduxAction<AppEnginePayload>) {
yield race({
task: call(startAppEngine, action),
cancel: take(ReduxActionTypes.RESET_EDITOR_REQUEST),
});
}
export default function* watchInitSagas() {
yield all([
takeLatest(ReduxActionTypes.INITIALIZE_EDITOR, startAppEngine),
takeLatest(ReduxActionTypes.INITIALIZE_PAGE_VIEWER, startAppEngine),
takeLatest(
[
ReduxActionTypes.INITIALIZE_EDITOR,
ReduxActionTypes.INITIALIZE_PAGE_VIEWER,
],
appEngineSaga,
),
takeLatest(ReduxActionTypes.RESET_EDITOR_REQUEST, resetEditorSaga),
takeEvery(URL_CHANGE_ACTIONS, updateURLSaga),
]);