fix: Handle saga watcher errors gracefully

This commit is contained in:
Maksim Eltyshev
2025-08-30 23:43:04 +02:00
parent d792e4064b
commit 2b5068de21
3 changed files with 27 additions and 4 deletions

View File

@@ -3,17 +3,18 @@
* 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 services from './services';
import runWatchers from '../run-watchers';
import selectors from '../../selectors';
import { socket } from '../../api';
import ActionTypes from '../../constants/ActionTypes';
import Paths from '../../constants/Paths';
export default function* coreSaga() {
yield all(watchers.map((watcher) => fork(watcher)));
yield runWatchers(watchers);
yield apply(socket, socket.connect);
yield fork(services.initializeCore);

View File

@@ -3,14 +3,15 @@
* 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 services from './services';
import runWatchers from '../run-watchers';
import ActionTypes from '../../constants/ActionTypes';
export default function* loginSaga() {
const watcherTasks = yield all(watchers.map((watcher) => fork(watcher)));
const watcherTasks = yield runWatchers(watchers);
yield fork(services.initializeLogin);

View File

@@ -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)));
}