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

Console flooded with "Non-Error promise rejection captured with value: undefined" #3095

Closed
koresar opened this issue Jan 12, 2020 · 4 comments
Closed

Comments

@koresar
Copy link

@koresar koresar commented Jan 12, 2020

Version

3.1.3

Reproduction link

https://exmaple.com/NOT_NEEDED

Steps to reproduce

I'm calling context.redirect("/") in Nuxt.js middleware. I've found the exact lines in vue-router source code where it rejects with undefined.

What is expected?

Promise rejections contain error object or do not reject.

What is actually happening?

Console is flooded with "Non-Error promise rejection captured with value: undefined". We receive huge amount of Sentry issues automatically caught as UnhandledRejection


The History.confirmTransition method calls the function abort() (stack trace shows this exact line

) which in turn calls onAbort(err) (stack trace shows this exact line
onAbort && onAbort(err)
) within the transitionTo method (stack trace shows this exact line:
onAbort(err)
)

The onAbort then calls reject(err) (as Promise rejection), but the err is undefined (because abort()).

I assume, that the rejection should never happen.

To my very limited knowledge this line:

onAbort && onAbort(err)

should be replaced with this:

err && onAbort && onAbort(err)
@koresar

This comment has been minimized.

Copy link
Author

@koresar koresar commented Jan 13, 2020

Could be as well Nuxt.js bug... They promisify the next router calls and could be that the promisificaiton went wrong.

@Kolobok12309

This comment has been minimized.

Copy link

@Kolobok12309 Kolobok12309 commented Jan 13, 2020

Have same problem

this.$router.replace('/');

In / redirect that throw error
Some bad fix

this.$router.replace('/', null, () => {});
@posva

This comment has been minimized.

Copy link
Member

@posva posva commented Jan 13, 2020

This is related to the promise api when no callbacks are passed to push/replace. You can find about it in the docs and an explanation behind the change at #2881 (comment)

@Kolobok12309 you should be able to find the answer in that comment

@koresar in your case, it's a bit different because you are using a redirect, which internally is probably calling next inside a beforeEach hook, causing a redirection, aborting the previous call of router.push/router.replace and causing that specific call to return a rejected promise. If that's not what you did, then I will need a boiled down repro (it can use Nuxt) to check it, ping me once you have one.

The Promise API for navigation will go through an RFC for the next version of Vue Router, especially for what should and should not reject the promise

@posva posva closed this Jan 13, 2020
@koresar

This comment has been minimized.

Copy link
Author

@koresar koresar commented Jan 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.