Ember.js: Unable to set 'error' route on 2.10

Created on 29 Nov 2016  ·  29Comments  ·  Source: emberjs/ember.js

Ember.js is setting the 'error' route by default, but route-recognizer does not allow duplicate routes anymore:
https://github.com/tildeio/route-recognizer/blame/5d54688f04273d3a921470b903a36266dddcdaf2/dist/route-recognizer.js#L525-L531

Doing so will give you a blank page with an error in your console:

Uncaught Error: You may not add a duplicate route named `error`

Default 'error' routes are set here:
https://github.com/emberjs/ember.js/blob/10857fd98008bb47bd63bfe3d21b0fc224a197a5/packages/ember-routing/lib/system/dsl.js#L49-L50

You can test it by trying to handle error route using ember g route error.
This functionality worked fine in 2.9 .

Bug Ember 2.10 Has Reproduction

Most helpful comment

Fixed in 2.11.1

All 29 comments

@diamondo25 Can you reproduce in a Twiddle please?

I'm seeing this as well and I don't recall seeing it in the most recent beta from yesterday

Seems legit. This is by virtue of a route-recognizer change I made. Need to lock out the default creation if the user has already created one. (I know how to fix, will get to it.)

@nathanhammond thanks for fixing so quickly! @rwjblue I labeled as "Bug" perhaps this issue can be resolved with an upcoming 2.10.1 release.

That's not the fix, @pixelhandler! That's where the bug was introduced. 😜This does need a point release once fixed, but I have a few other things to address before I can get back to do the router things. (I've got about 5 open issues to address.)

Is there a status on this guy?

We hit this issue upgrading the Bustle app to 2.10, and we'll need to either refactor our root error route to be named differently or hold off upgrading to 2.10.

We are also interested in the status of this bug. We are holding off from upgrading to 2.10 for the time being.

I was hoping I could work around this by not explicitly registering the error route and leaving my error template, route, etc. in place. I tried it and found:

  • On a failed route hook, the router will bubble up to the error route and my custom template is shown.
  • On a deliberate transition to error, the router does not transition to my template. Interestingly though, it does not log the same error message you get when a route doesn't exist.

I am thinking maybe I could leave the template, route, controller, etc. in place and register a custom error route pointing to the same template for my explicitly handled error cases. Maybe this would handle both the caught and uncaught errors with my custom template.

@nathanhammond - Do you have any thoughts on the above? Worth the hackery or better to just wait on an official fix?

Nevermind :(

The above proposal would still require the error mapping and would trigger this bug.

I may just go with making the custom route for my handled errors and using my same error component in the error template.

Seems to be the only other approach pending a fix.

CC: @nathanhammond

I've noticed that this is fixed in ember v2.12.0-beta.1, is there any chance to get this fix backported to a 2.11 release? Since the 2.12 beta introduces a whole bunch of new issues.

Since the 2.12 beta introduces a whole bunch of new issues.

Please report any issues you find with the beta cycle!

Is there any chance to get this fix backported to a 2.11 release?

Yes, I think that is a good idea.

It looks like this has been commented out in v0.2.9+ with 27c0f57 and 9b21d93 for the 0.3.x series.

@rwjblue would this just get patched back to 2.11 or 2.10 also? I am not sure of the process for deciding which bugs get patched in which version.

Fixed in 2.11.1

Was this fixed in a different way than beta.1? Just tried out 2.11.1 and that still gives me a duplicate route error about "hotel.error" while the beta doesn't.

@Glennvd - Yes they are different versions of route-recognizer (0.2.9 for 2.11 and 0.3 for 2.12). It is possible that I mucked this up somehow. Can you share the error and stack trace you get with 2.11? Also, possible a twiddle and/or demo repo? I'm happy to release a 2.11.2 once we figure out what I did wrong..

@rwjblue I've got a twiddle here, just needs to be changed to the right ember version https://ember-twiddle.com/e4b8412bf5629483f94276a001598571

Full stacktrace (from my own app) below.
add (ember.debug.js:55618) (anonymous) (ember.debug.js:57247) (anonymous) (ember.debug.js:55191) eachRoute (ember.debug.js:55179) eachRoute (ember.debug.js:55177) eachRoute (ember.debug.js:55177) map (ember.debug.js:55190) map (ember.debug.js:57244) _initRouterJs (ember.debug.js:27511) setupRouter (ember.debug.js:27606) startRouting (ember.debug.js:27592) startRouting (ember.debug.js:2887) didBecomeReady (ember.debug.js:3867) invoke (ember.debug.js:337) flush (ember.debug.js:405) flush (ember.debug.js:529) end (ember.debug.js:599) run (ember.debug.js:722) join (ember.debug.js:744) run.join (ember.debug.js:22286) (anonymous) (ember.debug.js:22349) mightThrow (jquery.js:3570) process (jquery.js:3638) nrWrapper ((index):97)
Error is still the same Uncaught Error: You may not add a duplicate route namedhotel.error.

@rwjblue running

grep --recursive "RouteRecognizer.VERSION" node_modules/ember-source

returns

node_modules/ember-source/dist/ember.debug.js:RouteRecognizer.VERSION = '0.2.8';
node_modules/ember-source/dist/ember.js:RouteRecognizer.VERSION = '0.2.8';
node_modules/ember-source/dist/ember.prod.js:RouteRecognizer.VERSION = '0.2.8';

Yeah, the issue is that [email protected] was released with 0.2.8's dist output. I'm working on it...

@rwjblue, Much appreciated sir.
Let me know if you need anything!

OK, I released [email protected] with the updated dist output, then bumped in the release branch (in https://github.com/emberjs/ember.js/commit/6c7e6950f127aa31912b5729971703c0c9615655), and confirmed in the build output (in https://github.com/components/ember/commit/4a9c7361f4f546daf3ad342da6d196b5b4b6bf20).

I then confirmed with the twiddle shared by @Glennvd above that when using release branch no assertion happens (and the app boots).

If someone else can sanity check me here, I can release 2.11.2...

On it.

@rwjblue forgive my noobiness,
I'm trying to build my project with

devDependencies: {
// ...
"ember-source": "git://github.com/emberjs/ember.js.git#6c7e6950f127aa31912b5729971703c0c9615655"
// ...

but it fails on

$ ember build
⠋ Building
Cannot find module 'node_modules/ember-source/dist/ember-template-compiler.js'

What am I doing wrong :)?

@gmaliar ember-source doesn't have the build artifacts in the repository, so you need to use the bower tag, or clone, build, and link ember locally.

Thanks @locks,
@rwjblue I can confirm it is working.

This can be closed, it works properly on 2.11.2.

Thanks for confirming!

Was this page helpful?
0 / 5 - 0 ratings