question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular Universal Prerender with simple RTDB query never finishes loading

See original GitHub issue

When running npm run prerender, the script never finishes loading when trying to prerender a route that has a simple query. Example from my project:

ngOnInit() {
    this.afdb.list(path, ref => ref.orderByChild('username').equalTo(username)).query.once('value').then(result => {
        console.log(result);
    });
}

The output in the terminal stays at “Prerendering 1 routes to …”. However, when I manually stop the script, the file in dist/project/browser will still be rendered correctly, which makes it seem like Universal is waiting for a subscription.

Angular: 11.0.2

Firebase: 8.1.1

AngularFire: 6.1.2

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

Failing test unit, Stackblitz demonstrating the problem

Steps to set up and reproduce

Sample data and security rules

Debug output

** Errors in the JavaScript console **

** Output from firebase.database().enableLogging(true); **

** Screenshots **

Expected behavior

Actual behavior

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
jamesdanielscommented, Nov 26, 2020

Most likely the Firebase JS SDK is setting up side-effects, a socket or a timer in a weird place, outside of where I am running zone.runOutsideAngular(() => ...). Previously in v8 they surprised me by setting up a timer when the reference is first constructed… I imagine there are other places. I’ll dig in at some point.

0reactions
jamesdanielscommented, Dec 1, 2020

Ah I thought someone added it to the database calls in the last batch of PRs but I must be misremembering.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Universal build hangs on prerendering page with ...
Basically if your http requests take too long the prerender hangs and won't finish. Same goes for the websocket connections(firebase uses WS ...
Read more >
Prerendering static pages
Angular Universal lets you prerender the pages of your application. Prerendering is the process where a dynamic page is processed at build time...
Read more >
Angular Universal: Complete Practical Guide
This post will be a complete practical guide for getting started with Angular Universal. We are going to go start with an existing...
Read more >
Angular Universal: Server-Side Rendering and Pre ...
When the client-side application has finished loading, the application switches from the pre-rendered app to the fully interactive client-side ...
Read more >
Angular Universal Example: Server Side Rendering (SSR), ...
Angular Universal Example: Server Side Rendering (SSR), Prerender · 1. Getting started with Angular 10 · 2. Routing and HttpClient implementation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found