angular-meteor icon indicating copy to clipboard operation
angular-meteor copied to clipboard

Infinite render loop for applications without a <base>

Open domq opened this issue 4 years ago • 0 comments

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 the templateUrl 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):

  1. git clone https://github.com/Urigo/angular-meteor-base.git
  2. Remove the <base> tag (that's what I did in my own start-from-scratch app, and that is what got me into trouble)
  3. 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
  4. Opt for the former approach, hit Stack Overflow and do this
  5. 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)
  6. Meditate
  7. 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 &lt;app> tag, which causes the infinite recursion)
  8. Go "aha, why don't I just set an absolute URL for the templateUrl?"
  9. Get no satisfaction
  10. Post this here issue

domq avatar Oct 08 '19 14:10 domq