Skip to content

State Rehydration with TransferState #555

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

Closed
Flood opened this issue Feb 5, 2018 · 8 comments
Closed

State Rehydration with TransferState #555

Flood opened this issue Feb 5, 2018 · 8 comments

Comments

@Flood
Copy link
Contributor

Flood commented Feb 5, 2018

Since we upgraded to the latest version of this repo our state rehydration fails.

Found this in app.module.server

// HttpTransferCacheModule still needs fixes for 5.0
    //   Leave this commented out for now, as it breaks Server-renders
    //   Looking into fixes for this! - @MarkPieszak
    //ServerTransferStateModule

Any ideas when this will be fixed? Can you @MarkPieszak point me in the right direction and then I can investigate as well.

@stephenlautier
Copy link

I'm trying to look into this as well, any help would be appreciated.

What i've discovered so far:

@stephenlautier
Copy link

update: what i noticed is when registering ServerTransferStateModule the universal beforeAppSerialized is not being triggered.. cant understand why because both uses multi: true

@stephenlautier
Copy link

update#2

So pretty much I have a working solution and got it working on our project, but it requires some changes, ideally in both angular and universal

  • Submitted an issue on angular Platform server - renderModuleFactory - module ref angular/angular#22049 - its a very simple change but its breaking, not sure if they agree to do so
  • Requires some changes in universal aspnetcore-engine tomorrow I will try to submit a PR to it, and move the breaking change temp in it gets accepted TransferState will work for aspnet 🎆

@MarkPieszak
Copy link
Member

@stephenlautier You rock!
Let me talk to the team and see if we can push in those changes asap so we can publish a new version of the engine etc out!

@Flood
Copy link
Contributor Author

Flood commented Feb 27, 2018

@MarkPieszak Any updates?

@MarkPieszak
Copy link
Member

A new update has been released (in angular/universal repo) about a week or so ago, can you give it a shot and let us know if it's working? @Flood

@Flood
Copy link
Contributor Author

Flood commented Mar 19, 2018

It seems to work! State rehydration works on my project but SSR does not. It breaks on

ERROR ReferenceError: Event is not defined (see angular/universal#844)

However, SSR works on this repo. I guess it will work on my project when the Event issue is solved.

@MarkPieszak
Copy link
Member

Excellent 👍
That might be coming from a third party library you have (?)

Just add global['Event'] = null; to your boot.server.ts file, and that should help the issue.

A lot of times you need to mock/stub things in Node to handle crazy global (typically browser-only items). Unfortunately a lot of people forget you should always check for the existence of global variables :(

Closing as TransferState works now 💃

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