redux-logic
redux-logic copied to clipboard
"warning: logic (~) is still running after 60s, forget to call done()?" keeps called
Hello. I am getting trouble after I updated redux-logic to latest version. I read all document and it said single-dispatch option is gone. So I added done() to all my logics. But I still get error message like below. I revised some source code to print 'action' in the last of error message due to insufficient information about logic name.
console.error: "warning: logic (L(/^(?!http\/).*/)-77) is still running after 60s, forget to call done()? For non-ending logic, set warnTimeout: 0", {"type": "GET_LOCATION"}
and below is my logic dealing with GET_LOCATION action.
`const getLocationLogic = createLogic({
type: 'GET_AUTH_LOCATION',
latest: true,
process: async ({getState, action}, dispatch, done) => {
axios.get('http://freegeoip.net/json/')
.then(res => {
dispatch(actionCreators.setLocation({
...someData here
}));
})
.catch(e => {
console.log(e);
})
.then(() => done());
}});`
What did I do wrong? It seems quite same as sample code of README.md. I am using RN 0.48.3 and Redux-logic 0.12.3. I appreciate in advance.
That looks correct. Does this happen consistently or just from time to time? Is is possible that the server doesn't respond within 60 seconds? (or maybe the browser is busy fetching other things and it gets queued and delayed?)
@jeffbski I think that's not the case. It happens every time I run the app and the response comes every time too. I've checked by logging 'res'. That logic runs right after the start up, and the warning message comes up far later.
I'm not an expert with async/await, but what is the purpose of your async clause in this case, as you are directly using promise .then()/.catch() directly? Is it possible that this is causing some anomaly?
I would suggest adding a log in the finally .then() clause to insure done() is being called.
@kevinAst oh that was a mistake.. Actually I created a logic using async/await at first and the warning message comes up. So I changed it to use promise to make it same as README. I forgot to delete async keyword then. I'll give a try without async and come again.
@KevinAst Unfortunately, it does not work. I think async keyword is not a problem. :(
@jh5696 I would still place some "temporary" diagnostic logs in each of the async callbacks. Of particular interest is to confirm that last "finally" then() clause is executing the done(). This might shed some light on what is actually happening. If the done() is being executed, then it points to some issue in redux-logic. If the done() is NOT being executed, then there is some issue with the promise.
@KevinAst Thanks for your reply. I tested with some logs and all seems good, but warning message still comes up. I confirmed that
- the response is definitely arrived within 60s(actually within a sec)
- done function is called in final then() clause after a dispatch
It's so strange. I added done after the promise but warning message still exists.
process: async ({getState, action}, dispatch, done) => {
axios.get('http://freegeoip.net/json/')
.then(res => {
dispatch(actionCreators.setLocation({
...someData here
}));
})
.catch(e => {
console.log(e);
})
.then(() => done());
done(); //I added this to test
};
done is called regardless of then/catch clauses. So It 'should' be and is actually called within 60s.. Dipatching setLocation is not executed as expected.
Thanks for looking into this. I'll go back and take a close look at the warning code and maybe it is a defect in redux-logic that the warning is not getting cancelled when it should be.
I haven't found anything wrong in the redux-logic code yet, but will still keep looking.
I did want to mention that this warning is only turned on in the development build. So once you are building and deploying in production (with NODE_ENV === 'production') then this warning is disabled.
I'll keep looking to see if I can figure out what might be going on.
@jeffbski I can reproduce this same issue FYI. One of our logic methods was failing and never actually executing done (even though it should be going to next .then(done) )
logic.js file
createLogic({
type: $requestPublicTokenData,
process({ getState, action }, dispatch, done) {
graphQueryPublic(publicTokenDataQuery, { user: action.user }).then(res => {
dispatch(receivePublicTokenData(res.publicAddresses, res.publicKnownContracts))
}).then(() => {
console.log('y u no call done?!?')
done()
})
}
}),
createLogic({
type: $requestPublicChartOfAccountsWithBalances,
process({ getState, action }, dispatch, done) {
graphQueryPublic(publicChartOfAccountsWithBalancesQuery, { user: action.user }).then(res => {
dispatch(receivePublicChartOfAccountsWithBalances(res.publicChartOfAccounts))
}).then(done)
}
}
graphQueryPublic utility looks like this:
export default (query, _variables) => {
const variables = Object.assign({}, _variables)
return axios.post(graphqlUrl, {
query,
variables
}).then(res => {
if (res.data.errors) {
// just got annoying so I created a filter for it
console.log('graphql error:', JSON.stringify(res.data.errors))
return res.data
} else {
return res.data.data
}
}).catch((err) => console.log('axios error:', err))
}
Thanks @james89 that should help me figure out what is going on. I'm thinking about maybe disabling the warning by default since maybe there are some edge cases where it is warning when it shouldn't and just causing more confusion than it is helping.
Running into this too, and I'm definitely calling done.
Here's my test code.
createLogic({
type: ActionType.CLICK_COUNT_UPDATED,
async process({ getState }, dispatch, done) {
const state: any = getState();
const count: number = state.dashboard.count;
console.log(`LOGIC ${ActionType.CLICK_COUNT_UPDATED}: count was incremented to ${count}`);
console.debug(await InternalHttpClient.execute(RxPublicApiEndpoint.publicTest));
done();
}
})
This is just senseless test code, but I did call done.
Still says warning: logic (L(CLICK_COUNT_UPDATED)-0) is still running after 60s, forget to call done()? For non-ending logic, set warnTimeout: 0
Did anyone end up figuring this out?
So, I had the same warning. I don't know if this will help anyone but, if in your Logic block you are running a transform and a process and the process is just passing along the data. You can just remove the pointless process and the error goes away.
const setPathLogic = createLogic({
type: actionNames.setPath,
transform({ action, getState }: IDependencies, next) {
const { path } = action as Actions.ISetPathAction;
const state = getState();
const storeId = storeDetailsSelectors.storeIdSelector(state);
const cleanPath = path..replace(':id', `${ storeId }`);
next({ ...action, path: cleanPath });
},
process({ action }, dispatch, done: VoidFunction) {
const { path } = action as Actions.ISetPathAction;
return { ...action, path };
done();
},
});
Will just become this:
const setPathLogic = createLogic({
type: actionNames.setPath,
transform({ action, getState }: IDependencies, next) {
const { path } = action as Actions.ISetPathAction;
const state = getState();
const storeId = storeDetailsSelectors.storeIdSelector(state);
const cleanPath = path..replace(':id', `${ storeId }`);
next({ ...action, path: cleanPath });
},
});
And there you go the error stops occurring.
I'm getting this error. I'm using transform, not process, and this error occurs.
Why does this error message exist? Isn't async/await all we need?
If you don't call a return you need a done. I'm pretty sure that is the rule.
Get Outlook for Androidhttps://aka.ms/ghei36
From: Rob Christian [email protected] Sent: Friday, April 26, 2019 11:21:46 PM To: jeffbski/redux-logic Cc: Charles Givens; Comment Subject: Re: [jeffbski/redux-logic] "warning: logic (~) is still running after 60s, forget to call done()?" keeps called (#81)
I'm getting this error. I'm using transform, not process, and this error occurs.
Why does this error message exist? Isn't async/await all we need?
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jeffbski_redux-2Dlogic_issues_81-23issuecomment-2D487250456&d=DwMCaQ&c=AT5K1q9CQPGMXclhopmqpg&r=rzqzrW2bZcenS3C0KeZ4yAal9aY7so6DbhE_7ApOmAQ&m=mO_MNPqsplx2zDvWK-ZMmGHMwMy4MqVeCOOuBfXSdtY&s=gtpoqArFNwtAGO3GHGgUW_FN73nRyXrikzIKsRltYD0&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AJ2JHVIMFXYG26A6WLXUFYDPSPBEVANCNFSM4D5UACKQ&d=DwMCaQ&c=AT5K1q9CQPGMXclhopmqpg&r=rzqzrW2bZcenS3C0KeZ4yAal9aY7so6DbhE_7ApOmAQ&m=mO_MNPqsplx2zDvWK-ZMmGHMwMy4MqVeCOOuBfXSdtY&s=y5j_R7gUvMRvrl-j891bIfUeJGo7DWer5US0IXnsrpI&e=.
CONFIDENTIALITY NOTICE: This message contains information which may be confidential or privileged. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this transmission in error, please notify me immediately by telephone.