angular-meteor
angular-meteor copied to clipboard
Infinite render loop for applications without a <base>
Because of the unfortunate combination of the following facts,
- Meteor serves the entire app on any URL that it doesn't recognize,
-
angular-typescript-compiler
insists on taking control of thetemplateUrl
so that it doesn't matter whether said URL is absolute or relative — The template always gets fetched from the current URL directory (absent a<base>
tag in the HTML<head>
), -
RouterModule
demands a base URL, and the first suggestion it provides is the one that fails to paper over the previous issue,
... it is quite easy to run into the situation where the app tries to render itself recursively, ad infinitum.
This appears to have happened before to other people.
Steps that lead me here (with step-by-step reproduction instructions provided in my clone of angular-meteor-base
):
-
git clone https://github.com/Urigo/angular-meteor-base.git
- Remove the <base> tag (that's what I did in my own start-from-scratch app, and that is what got me into trouble)
- Get error message from router:
No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document
- Opt for the former approach, hit Stack Overflow and do this
- Browse http://localhost:3000/foo/bar and get infinite loop (
Maximum call stack size exceeded ; Zone: <root> ; Task: Promise.then ; Value: RangeError: Maximum call stack size exceeded
) - Meditate
- Using the Chrome dev tools, discover that the app is issuing a query to
http://localhost:3000/foo/client/imports/app/app.html
, emphasis on/foo/
(which Meteor will serve the entire app for, including another occurence of the<app>
tag, which causes the infinite recursion) - Go "aha, why don't I just set an absolute URL for the
templateUrl
?" - Get no satisfaction
- Post this here issue