fix: Handle saga watcher errors gracefully
This commit is contained in:
@@ -3,17 +3,18 @@
|
|||||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { all, apply, fork, select, take } from 'redux-saga/effects';
|
import { apply, fork, select, take } from 'redux-saga/effects';
|
||||||
|
|
||||||
import watchers from './watchers';
|
import watchers from './watchers';
|
||||||
import services from './services';
|
import services from './services';
|
||||||
|
import runWatchers from '../run-watchers';
|
||||||
import selectors from '../../selectors';
|
import selectors from '../../selectors';
|
||||||
import { socket } from '../../api';
|
import { socket } from '../../api';
|
||||||
import ActionTypes from '../../constants/ActionTypes';
|
import ActionTypes from '../../constants/ActionTypes';
|
||||||
import Paths from '../../constants/Paths';
|
import Paths from '../../constants/Paths';
|
||||||
|
|
||||||
export default function* coreSaga() {
|
export default function* coreSaga() {
|
||||||
yield all(watchers.map((watcher) => fork(watcher)));
|
yield runWatchers(watchers);
|
||||||
|
|
||||||
yield apply(socket, socket.connect);
|
yield apply(socket, socket.connect);
|
||||||
yield fork(services.initializeCore);
|
yield fork(services.initializeCore);
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { all, call, cancel, fork, take } from 'redux-saga/effects';
|
import { call, cancel, fork, take } from 'redux-saga/effects';
|
||||||
|
|
||||||
import watchers from './watchers';
|
import watchers from './watchers';
|
||||||
import services from './services';
|
import services from './services';
|
||||||
|
import runWatchers from '../run-watchers';
|
||||||
import ActionTypes from '../../constants/ActionTypes';
|
import ActionTypes from '../../constants/ActionTypes';
|
||||||
|
|
||||||
export default function* loginSaga() {
|
export default function* loginSaga() {
|
||||||
const watcherTasks = yield all(watchers.map((watcher) => fork(watcher)));
|
const watcherTasks = yield runWatchers(watchers);
|
||||||
|
|
||||||
yield fork(services.initializeLogin);
|
yield fork(services.initializeLogin);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright (c) 2024 PLANKA Software GmbH
|
||||||
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { all, call, spawn } from 'redux-saga/effects';
|
||||||
|
|
||||||
|
function* safeWatch(watcher) {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
yield call(watcher);
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error); // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function* runWatchers(watchers) {
|
||||||
|
return yield all(watchers.map((watcher) => spawn(safeWatch, watcher)));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user