A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue-router/issues/2881 below:

No stacktrace on NavigationDuplicated error uncaught in promise · Issue #2881 · vuejs/vue-router · GitHub

Version

3.1.1

Reproduction link

https://jsfiddle.net/Lom7hxn5/

Steps to reproduce
  1. Call $router.replace or $router.push twice with same path
What is expected?

Error object provides stacktrace (stack property)

What is actually happening?

No stack trace in the error object

When NavigationDuplicated error is thrown, there is no stack trace in the error itself so when error is reported through error reporting service like Sentry, there is absolutely no context to go with the error and so it's hard to figure out where that error originated.

Transpiled code for the NavigationDuplicated class looks like this:

var NavigationDuplicated = /*@__PURE__*/(function (Error) { function NavigationDuplicated () { Error.call(this, 'Navigating to current location is not allowed'); this.name = this._name = 'NavigationDuplicated'; } if ( Error ) NavigationDuplicated.__proto__ = Error; NavigationDuplicated.prototype = Object.create( Error && Error.prototype ); NavigationDuplicated.prototype.constructor = NavigationDuplicated; return NavigationDuplicated; }(Error));

which is problematic because instantiating such function won't create a stacktrace. It would work fine with non-transpiled code (although I'm not suggesting to not transpile it):

export class NavigationDuplicated extends Error {

One possible solution would be to manually set stack trace with:

this.stack = (new Error()).stack;

but I'm not sure how that would be done if transpilation is done by webpack/babel...

There is also one extra bug in that code. The line that instantiates error passes a route object to the error:

return abort(new NavigationDuplicated(route))

but error doesn't do anything with it:

Saving route properties on the error object would also help in deciphering source of the error.

marvinhagemeister, claudivanfilho, ashtonian, stephpasquini, sergioflores-j and 16 moreclaudivanfilho, andreasvirkus, mihlek1 and rizkyyoga


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4