Custom `locationType` Causes `cannot GET /foo` with `ember serve`

TL;DR: Added custom location type to environment.js then ember serve → open browser to route /foo → cannot GET /foo

Followed the instructions at Location - 4.6 - Ember API Documentation and copied the code exactly as it appeared into a file called app/locations/history-url-logging.js, added a line to config/environment.js that said:

ENV.locationType = 'history-url-logging';

For reference, the code given in the docs is simply:

import Ember from 'ember';

export default Ember.HistoryLocation.extend({
	implementation: 'history-url-logging',

	pushState: function (path) {
		console.log(path);
		this._super.apply(this, arguments);
	}
});

I decided to restart the server, did the usual CTRL+C to ember s then did ember s again. I went back to my browser sitting on one of the routes, hit F5, and received the cryptic error:

Cannot GET /contacts

So, after MUCH Googling and trial and error, I discovered that to FIX that error, all I had to do remove the config line ENV.locationType = 'history-url-logging';, restart the server (ember s), and suddenly the app worked fine!

What’s even more odd is that if I start the app without that line in environment.js, then once the app is running (and the browser window reloads just fine, etc), then I re-add the line that says ENV.locationType = 'history-url-logging'; (which triggers a live reload), and the app still works fine! (E.g. hitting F5 to reload the page doesn’t vie me the “Cannot GET /contacts” (or whatever the route is) error.) And, of course, the console gives me the “console.log” output as expected from the code above.

So, long and short of it, using a custom location totally seems to screw up ember serve - which is really sad and frustrating! Any ideas how to fix this?

[Full disclosure: Posted on SO #44223927 with no resolution]

I would think this is correct. But perhaps it works with this._super(...arguments); like here?

https://github.com/emberjs/api/blob/6b6e331dcc28aa831bcf984d429e59ca6992f278/app/locations/history.js

I would think the two syntaxes are identical, besides, that code was copied straight from the documentation. Are you saying you get no errors with Ember serve running that custom location?

I have not tested yet but I think that if you overwrite locationType with your type you lose the auto type even if you call _super.

If you rename your file to app\locations\history.js it works when you leave locationType on auto. So it seems that if you write your own you have to include all methods because it states Each location implementation must provide the following methods here Location - 4.6 - Ember API Documentation