Discovered during debugging of a weird saga hang issue here https://github.com/yelouafi/redux-saga/issues/304#issuecomment-217727607 – the sagas weren't terminating after dispatching the END action, even if they consisted only from fork and take effects.
The culprit was the middleware that timestamps all the actions (adds meta: { timestamp: 1234567890 }), but does this by re-creating the action objects as if they were immutable:
export default function actionTimestampMiddleware() {
return () => (next) => (action) => {
if (typeof action === 'object') {
// Add `meta.timestamp` of the dispatch time to all action objects.
const nextAction = {
...action,
meta: {
...action.meta,
timestamp: Date.now(),
},
};
return next(nextAction);
}
return next(action);
};
}
This changes the reference of the END action, which results in the action being unhandled inside the redux-saga. The internals compare the action by reference, not by the string action type, so the re-created action object doesn't pass the checks.
I found the following places where this may occur, but there may be more:
CC @yelouafi
Thanks for the catch. I'll fix this in the next patch
FYI fixed in 0.10.3
@yelouafi Thanks!
Most helpful comment
FYI fixed in 0.10.3