Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate app state in prerendered page #128

Open
spencerodai opened this issue Jul 20, 2021 · 8 comments
Open

duplicate app state in prerendered page #128

spencerodai opened this issue Jul 20, 2021 · 8 comments

Comments

@spencerodai
Copy link

hi @chrisguttandin, I am able to use this package to successfully, the only thing is that I get duplicate data states for example, I have <script id="serverApp-state"></script> injected twice where serverApp is the appId assigned to BrowserModule.withServerTransition({ appId: 'serverApp' }), and as a result, Browser transfer state mechanisms do not work. is this something that the package does intentionally and how can I get around it.

nb. when I delete the extra <script id="serverApp-state"></script>, transfer state works fine.

@chrisguttandin
Copy link
Owner

Hi @spencerodai,

thanks for reporting this. I wasn't aware of the problem so far. I made a quick check and it looks like all the apps that I use with angular-prerender don't have this problem. Is your project available somewhere? Or if not could you create a small example which reproduces the problem?

This might of course be totally wrong, but my first guess would be that you somehow prerender the same HTML document twice. Is that possible?

@spencerodai
Copy link
Author

thanks for your reply, I will investigate this further.

I have another question, is there a way to pass a txt file with the defined routes in the command to prerender pages, as opposed to entering a space delimited list?

@chrisguttandin
Copy link
Owner

Hi @spencerodai, sorry for the delay. You mean a file based replacement for the --include-routes flag? Such an option doesn't exist so far. Feel free to create a separate issue for that if you want it to be added. ;-) Doesn't retrieving the routes automatically work for you use case?

Any use on the duplicate app state problem you're experiencing?

@spencerodai
Copy link
Author

thanks for getting back to, no in my app, I am not able to pick up the routes automatically and this is actually desirable in our case. we will be prerending over 20000 pages and its tasking for out ci/cd process so we wanted to have a bit more control and only prerender sections of the app on some deployment event. we also wanted to be able to pass in a route that has edited by our CMS and prerender that page only for example.

As for duplicate state, I think I know the problem and its from my app, not angular-prerender, but I haven't gotten around to fixing this yet.
I will create a feature request for potentially passing in a url to a txt file with prerender routes.

Thanks a bunch

@chrisguttandin
Copy link
Owner

Hi @spencerodai, I definitely understand that rendering 20000 pages only because one of them changed is not desirable. :-)

I guess that means you ideally also want to turn off the route parsing entirely, right? Right now that can't be done.

@mfrancekovic
Copy link

I'm having the same issue with the duplicate app state problem.

What's weird though is that when I run the prerender locally there is only one state script in each file. And when I run the prerender on my CI/CD (GithubActions), it creates a double state script - and the thing breaks because of that.

I can't seem to figure it out. @spencerodai have you had some breakthrough? 🙏

@spencerodai
Copy link
Author

@mfrancekovic I never got around to it as we decided to use angular universal prerenderer instead

@chrisguttandin
Copy link
Owner

@mfrancekovic Is the project (including the GitHub Actions) publicly available somewhere? Or do you know of another way for me to reproduce the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants