yield promise in a generator function issue
Author: ppalbuquerqueCreated Nov 19, 2025Updated Jul 21, 2026
In the project I'm working on, we have the following code where apiService.fetchInfo() returns a promise. The problem I'm facing is that sometimes the code does not reach the EventEmitter.emit line, even when the fetch is successful. Is there an issue with yielding the promise directly instead of using a call effect?
function* _fetchInfo() {
try {
const data = yield apiService.fetchInfo()
if (!data) return
EventEmitter.emit(
GENERIC_EVENT,
data,
)
return data
} catch (e) {
yield put(fetchFailed())
}
}
Source: redux-saga/redux-saga