react-toastify
react-toastify copied to clipboard
Not processing toast.promises in the background with low limit of ToastContainer
The bug is related to the incorrect processing of promises. In my case, I have to queue a lot of notifications that are tightly dependent on network requests, that may take some time to process. Currently, for some reason, after queueing more promises that are available in the set limit of ToastContainer we get a forever pending promise, that can't somehow be resolved. FYI I can't increase the limit of visible toasts. I have provided a sandbox in case someone doesn't understand the issue. So when the limit is 3, and you try to click the 'Notify' button multiple times (for example 10), after resolving 3 first promises, other ones will be left in a pending state forever.
https://codesandbox.io/s/lingering-cookies-3545w?file=/src/index.js
The expected behavior is in resolving all promises correctly, without any left in pending state.
Hello!
Same issue here, did you find a solution by any chance?
You might try to set a unique Id to the toast, so this problem won't appear if multiple requests for the same operation are coming, as shown in my Sandbox. By setting { toastId: 'something' } you will omit the problem for obvious reasons - only one promise will be handled. But in case there are a lot of them and they are different, this is impossible due to the specifics of the mechanisms that are used inside the library. I haven't found a trivial solution to this one by inspecting the code.
@Elugormo Thanks for your answer, it's a bit helping although still an issue..
It appears to work ordinarily if you pass any updateId
on Promise
toast invocation (perhaps in conjunction with a toastId
), but this in turn will violate the limit
property, whereby each appearing Promise
toast will push the other toasts beyond that threshold.