Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

On SSR gives ReferenceErrors for window and document #18

Open
anelad opened this issue Nov 1, 2019 · 15 comments · Fixed by #19
Open

On SSR gives ReferenceErrors for window and document #18

anelad opened this issue Nov 1, 2019 · 15 comments · Fixed by #19
Labels
bug Something isn't working

Comments

@anelad
Copy link

anelad commented Nov 1, 2019

The first thing is first; it works on SSR.

But gives console errors on page loads.

At first load of the app; it gives ReferenceError: window is not defined. Full output:

ReferenceError: window is not defined
    at Object.Z8CG (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:159033:3)
    at __webpack_require__ (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:20:30)
    at new StickyDirective (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:150795:9)
    at createClass (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:79786:20)
    at createDirectiveInstance (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:79606:22)
    at createViewNodes (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:90886:38)
    at callViewAction (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:91336:13)
    at execComponentViewsAction (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:91241:13)
    at createViewNodes (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:90915:5)
    at createRootView (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:90758:5)

When surfing between pages after the app is loaded, it gives ERROR ReferenceError: document is not defined. Full output:

ERROR ReferenceError: document is not defined
    at StickyDirective.generateSentinelElement (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:150948:28)
    at StickyDirective.putSentinel (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:150966:31)
    at StickyDirective.ngAfterViewInit (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:150859:14)
    at callProviderLifecycles (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:80127:18)
    at callElementProvidersLifecycles (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:80092:13)
    at callLifecycleHooksChildrenFirst (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:80074:29)
    at checkAndUpdateView (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:90957:5)
    at callViewAction (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:91313:21)
    at execComponentViewsAction (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:91241:13)
    at checkAndUpdateView (/Volumes/WD_RAID/Documents/Projects/Web/medyaeli website/dist/server/main.js:90954:5)
@dianjuar
Copy link
Member

dianjuar commented Nov 1, 2019

@osnoser1 you as an expert of SSR can you give me your opinion here?

@anelad
Copy link
Author

anelad commented Nov 1, 2019

@dianjuar I'm always thrilled with your response time 🔥 🤣

@dianjuar
Copy link
Member

dianjuar commented Nov 1, 2019

@anelad Do you have a repo of your problem ?
I can tell you that I kwon what SSR is about but I don't have any code experience with that

@anelad
Copy link
Author

anelad commented Nov 1, 2019

I can create a basic git repo. But I'm afraid its gonna take some time since I'm highly busy right now.

@osnoser1
Copy link
Contributor

osnoser1 commented Nov 4, 2019

Sorry for the delay @dianjuar.
I created a PR with the fix: #19 😄

@anelad
Copy link
Author

anelad commented Nov 4, 2019

@dianjuar @osnoser1 I think there is no need for a repo of the problem now?

@dianjuar
Copy link
Member

dianjuar commented Nov 4, 2019

@osnoser1 THANK YOU!!!!
I just ask for your opinion and you ended up making a PR! What a such friend!
Thank you so much

@dianjuar
Copy link
Member

dianjuar commented Nov 4, 2019

@dianjuar @osnoser1 I think there is no need for a repo of the problem now?

I think there is no longer necessary

@dianjuar dianjuar added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Nov 4, 2019
@dianjuar
Copy link
Member

dianjuar commented Nov 8, 2019

@anelad deploying...

@anelad
Copy link
Author

anelad commented Nov 8, 2019

Thank you @dianjuar

@dianjuar
Copy link
Member

dianjuar commented Nov 8, 2019

@osnoser1 take a look at this ----> https://travis-ci.org/bikecoders/ngx-sticky
When installing the dependencies is compiling something and fails installing it... Do you know the reason ?

@dianjuar
Copy link
Member

dianjuar commented Nov 8, 2019

@anelad I just publish the package with your solution on the @next tag.
You can install it by npm install ngx-sticky-directive@next

I am having issues with travis ci that, it's design to make the deployment automatically but is failing installing some dependencies. So until I fix that awful CI you can make your test with that version of the package.

I will reopen the issue until I fix it. Please tell me how it goes.

Sorry for the delay on this.

@dianjuar dianjuar reopened this Nov 8, 2019
@dianjuar dianjuar mentioned this issue Nov 12, 2019
10 tasks
@dianjuar
Copy link
Member

dianjuar commented Apr 7, 2020

@osnoser1, We're migrating this package to Nx and making compatibility with Angular9.

I know too little about SSR, could you give us the instructions to know how to unit test the feature that you added? I want to have this feature always present on every change that we made from now on. I want to have the unit test for it.

@osnoser1
Copy link
Contributor

osnoser1 commented Apr 8, 2020

@dianjuar one of the ssr problems it's complex test that feature, in fact it is in the TODO of Angular Universal as you can see here.

I would have to think how to implement unit tests to the feature.
Tomorrow I review the source code of this project to think of a good strategy.

@dianjuar
Copy link
Member

dianjuar commented Apr 8, 2020

@osnoser1 that was the information that I needed please don't mind.

And how test it manually? The reason for my concern is that we are migrating to Nx #25 and I want to at least test it manually.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants