Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Promise success clears when 2nd promise has undefined success #1110

Open
hufftheweevil opened this issue May 5, 2024 · 2 comments
Open

Comments

@hufftheweevil
Copy link

What is the current behavior?

When calling two promises in a row, if one has a success defined, but the other does not, then the first one closes instantly. Example:

await toast.promise(async () => {}, {
  success: 'Success on 1'
})
await toast.promise(async () => {}, {
  // success: 'Success on 2',
  error: 'Error on 2'
})

If you uncomment the success on the 2nd one, then all works well.


What is the expected behavior?

success shouldn't be required. When absent, it shouldn't affect other toasts.

Note: Adding a toastId does not help.


Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

React v18.2.0; not tested in other versions
Tested in Chrome and Firefox

BTW, awesome package! Simple and beautiful.

@hufftheweevil
Copy link
Author

Doing some more testing, I found that adding a pending to (at least) the 2nd call will yield the expected the results.

But looking through the code, it shouldn't be required. If no pending is given, then no id is set inside handlePromise(), so when it's time to resolve(), it should be creating a fresh new toast and not touch the other. I can't figure out why it's affecting the other.

@hufftheweevil
Copy link
Author

Found the issue, PR submitted #1112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant