ngx-formly: Universal SSR render error - Cannot read property 'hooks' of undefined

I’m submitting a … (check one with “x”)

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request

Current behavior Visiting a page with a formly form rendered by Angular Universal SSR, I get an error, the page doesn’t load at all. The same page renders fine if rendered by browser.

TypeError: Cannot read property 'hooks' of undefined
    at FormlyField.triggerHook (/home/test.universaledition.com/web/dist/server.js:171488:24)
    at FormlyField.ngOnDestroy (/home/test.universaledition.com/web/dist/server.js:171432:14)
    at callProviderLifecycles (/home/test.universaledition.com/web/dist/server.js:77721:18)
    at callElementProvidersLifecycles (/home/test.universaledition.com/web/dist/server.js:77689:13)
    at callLifecycleHooksChildrenFirst (/home/test.universaledition.com/web/dist/server.js:77679:29)
    at destroyView (/home/test.universaledition.com/web/dist/server.js:85875:5)
    at callViewAction (/home/test.universaledition.com/web/dist/server.js:86001:13)
    at execEmbeddedViewsAction (/home/test.universaledition.com/web/dist/server.js:85944:17)
    at destroyView (/home/test.universaledition.com/web/dist/server.js:85873:5)
    at callViewAction (/home/test.universaledition.com/web/dist/server.js:86001:13)

Expected behavior Page should render with the form without any complications, no matter if it’s SSR or browser rendered.

Please tell us about your environment: using @nguniversal/express-engine for SSR (Node Express server) Latest version of ngx-formly (5.5.1) All libraries updated via npm update.

  • Angular version: 8.2.11

  • Browser: [all]

  • Language: [all]

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@eng-dibo fixed in v5.6.0 release.

the above changes are located in your server.ts file which part of your source code and not node_modules

use the following workarround until the new version is released.

const win = createWindow(template);
global['window'] = win.window;
global['document'] = win.document;
global['navigator'] = win.navigator;
global['localStorage'] = win.localStorage;
+ // TODO: remove after updating to formly `5.5.2`
+ global['FileList'] = Object;
+ global['File']= Object;
+ global['Blob'] = Object;