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.

Silent fail of preprendering

See original GitHub issue

🐞 Bug report

Hi guys, firstly, I wanted to say thanks for your hard work, truly appreciate that 🙌

What modules are related to this issue?

  • builders, but I’m not sure
  • common
  • express-engine

Is this a regression?

Probably, no

Description

So, I was playing around with the prerendering feature, but faced an issue - some of my routes were empty after prerendering script was executed successfully (a pre-rendered page contained only <router-outlet></router-outlet><!----> instead of the component’s template). It seems that I was able to track it down. The issue only appears when I’m using localStorage in the component, but, I guess that could also be affected by the usage of any browser-specific API.

I believe that prerender script should either fail or show some kind of warning in case non-existent API (in the context of server) is used.

🔬 Minimal Reproduction

  1. Initialize app via latest Angular CLI
  2. Add universal
  3. Add a new route/component. E.g.: a lazy module dashboard
  4. Call localStorage.getItem in the constructor of the new component
  5. Call prerender script (npm run prerender -- --routes /dashboard /)
  6. See dist/unversal-test/browser/dashboard/index.html, there is content from src/app/dashboard/dashboard.component.html. And, there are no errors/warnings in the console

Here is the repository where I reproduced the issue, https://github.com/chernodub/ng-universal-reproduced-prerender-issue This is a breaking change https://github.com/chernodub/ng-universal-reproduced-prerender-issue/commit/656945bd4ad78e085f89fa30ad3d3c8e5acdc524, without it, prerender works fine

🔥 Exception or Error

No error or warning, that’s the problem. In case the application is somehow complex/advanced it may be very hard to understand, why prerender didn’t work 😦

🌍 Your Environment

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
alan-agius4commented, Aug 4, 2022

After looking a bit into this, it appears that the router is not re-throwing the error

Basically the below is not working as intended. https://github.com/angular/angular/blob/d583f85701b0424496e263bf1cbc2c619869437e/packages/router/src/router.ts#L1398-L1402

0reactions
alan-agius4commented, Aug 5, 2022

@atscott, I debugged this a bit more and as suspected this is indeed caused by the floating promises.

I tried to remove a number of floating promises (By patching the node_modules directly) and did indeed result in the error to bubble up correctly to the prerender worker.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular - Prerender command fails and errors - Stack Overflow
If you are sending an HTTP request in oninit hook or similar hooks, which will be rendered as soon as component instantiates, like...
Read more >
Error Boundaries - React
Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them. Note. Error boundaries do not...
Read more >
Unable to prerender all routes! - Chrisvfritz/Prerender-Spa-Plugin
Unable to prerender all routes! ... The preprender dependency of this package has an issue identified by one of our team, they'll submit...
Read more >
atscott (atscott)
Unable to access all router params from the service or the resolver. 2 Likes 1 Replies ... Silent fail of preprendering. 1 Likes...
Read more >
Migrate the parser test suite from AngularDart to Angular 2,about ...
scroll back to top is missing HOT 1; Silent fail of preprendering HOT 6; Input attribute ... Production build removes important information from...
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