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

Fix issues with SSR builds by adding window bind and Date reference. #717

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

cozzbie
Copy link
Contributor

@cozzbie cozzbie commented Nov 8, 2019

Running an SSR build with this lib in Angular produces

/.../dist/server.js:353
                        throw error;
                        ^

TypeError: Cannot read property '_listeners' of undefined
    at addEventListener (/.../dist/server.js:95761:15)
    at Object._ (/.../dist/server.js:183273:5)
    at init (/.../dist/server.js:183283:14)
    at Timeout.<anonymous> (/.../dist/server.js:183290:4)
    at ZoneDelegate.module.exports.ZoneDelegate.invokeTask (/.../dist/server.js:577:31)
    at Zone.module.exports.Zone.runTask (/.../dist/server.js:349:47)
    at module.exports.ZoneTask.invokeTask (/.../dist/server.js:652:34)
    at Timeout.ZoneTask.invoke (/.../dist/server.js:641:48)
    at Timeout.timer [as _onTimeout] (/.../dist/server.js:2386:29)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

This is because during the registration of listeners, the reference is lost. Binding to window corrects this but introduces another issue where the Date method of the window is also lost and this throws as well. Passing the Date as a reference also corrects this.

@cozzbie
Copy link
Contributor Author

cozzbie commented Nov 8, 2019

Hi @aFarkas. Please see critical update that my team depends on. I am available for any questions. Thanks

@cozzbie cozzbie changed the title Fix issues with SSR builds in Angular. Fix issues with SSR builds by adding window reference. Nov 8, 2019
@cozzbie cozzbie changed the title Fix issues with SSR builds by adding window reference. Fix issues with SSR builds by adding window bind and Date reference. Nov 8, 2019
@aFarkas aFarkas merged commit 55f936b into aFarkas:gh-pages Nov 8, 2019
@cozzbie
Copy link
Contributor Author

cozzbie commented Nov 11, 2019

Hi @aFarkas. Can you please update the npm package as it seems to still be the previous version. Thanks.

@aFarkas
Copy link
Owner

aFarkas commented Nov 13, 2019

@cozzbie
Yeah, I was a little bit sick and want to make some changes before. But I will release a beta version that you can reference. It will take max one week until I release a final version.

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

Successfully merging this pull request may close these issues.

None yet

2 participants