-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Animations causing problems with SSR: document is not defined #15098
Comments
Same error with the same config. |
+1 |
Here is repository where last commit simulates error: https://github.com/kukjevov/ng-universal-demo It looks like that this https://github.com/angular/angular/pull/14880/files PR started this bug, or it is somehow connected to this. @chuckjaz, @tbosch can you look at this :)? Thank you |
Same error happens when using in Universal context |
I got the same error upgrading to v4-rc.3 when using material2-beta2 (and the Menu component which uses animations). |
@feloy Are you using Server Side Rendering (SSR) aka Universal ? Because this error happens in NodeJs environment, not in browser, but during rendering on server side. I have |
@kukjevov Well, no, I got the same error (Error: Found the synthetic property ... Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.) but in the browser. My answer were not directly directed to you, but placed here if somebody had the same error in my context (using Material in the browser), because your description helped me resolve my problem. It was not very clear, sorry ;) |
No problem :), but that server side part is a bug :). |
Probably duplicate of #14784 |
It is not duplicate :). Recomended solution in #14784 cause error mention above document is not defined. |
Ran into the same problem. If you need a fix you can patch the server renderer to ignore the error: import { ɵServerRendererFactory2 } from '@angular/platform-server';
const createRenderer = ɵServerRendererFactory2.prototype.createRenderer;
ɵServerRendererFactory2.prototype.createRenderer = function () {
const result = createRenderer.apply(this, arguments);
const setProperty = result.setProperty;
result.setProperty = function () {
try {
setProperty.apply(this, arguments);
} catch (e) {
if (e.message.indexOf('Found the synthetic') === -1) {
throw e;
}
}
};
return result;
} |
I'm not using SSR, but Angular Material Beta.2 gives me the following error with 4.00-rc.2 when I run ng serve (this app works fine in Angular 2): Error: Found the synthetic property @transformPlaceholder. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application. |
@yfain - Unrelated to this bug. You should include BrwoserAnimationModule in your app module as the error indicates. |
Yes, I actually fixed this issue by adding import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; to the app.module. |
…efault (angular#15131) This is so that server side rendering does not throw an exception when it encounters animations on the server side and does not need the user to explicitly setup NoopAnimationsModule in their app server module. Fixes angular#15098, angular#14784. PR Close angular#15131
I sitll have the same Error in Angualr 4.0.2 Universal ZoneAwarePromise { |
Same thing for me:
|
update for the last release but sitll i have the same errorr (Angular 4.0.3) Universal
repo: |
I still see this error in 4.1.0... @MikeRyanDev where do you apply that patch? |
I still see this issue with angular universal running 4.0.0. Does 4.1 fix this? |
I have Same error in 4.1.0,how to resolve this problem? thanks @kukjevov |
@BillyQin I just figured it out after the long day search, hope this helps
|
thank you! this fixed my issue. |
…efault (angular#15131) This is so that server side rendering does not throw an exception when it encounters animations on the server side and does not need the user to explicitly setup NoopAnimationsModule in their app server module. Fixes angular#15098, angular#14784. PR Close angular#15131
…efault (angular#15131) This is so that server side rendering does not throw an exception when it encounters animations on the server side and does not need the user to explicitly setup NoopAnimationsModule in their app server module. Fixes angular#15098, angular#14784. PR Close angular#15131
I am still experiencing this issue, and not really sure what the ultimate resolution was for this thread. Angular 4.2.5. |
@sudippal Hi can you please elaborate your solution? I am facing the same issue while server side rendering to serve a fully generated HTML page in server.ts
|
To solve the SSR issue I just created 3 modules - a Common module, a Browser module, and a Server module... app-material.module.ts (common one)
app-material.module.server.ts (import the common one here)
app-material.module.browser.ts (import the common one here)
Now just import the one you need into your main module |
I too had this error. However, I was able to resolve the error by importing `import { NgModule } from '@angular/core'; // App @NgModule({ export function getBaseUrl() { |
In my case i did add the import of BrowserAnimationsModule to the top of app.module.ts but i forgot to add it to the imports array. after adding it my issue was fixed. |
In my case I was importing NoopAnimationsModule before BrowserAnimationsModule like this:
Just switch the order so that BrowserAnimationsModule is first:
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
When i use animations in HTML, SSR crashes.
I have my animation defined and used in html like this
I have browser module which imports
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
I received error on server
Error: Found the synthetic property @flyin. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.
When i import in server module
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
i receive another error which cause crash of server.
EXCEPTION: document is not defined
ORIGINAL STACKTRACE:
ReferenceError: document is not defined
at DefaultDomRenderer2.selectRootElement (F:\git\ng-universal-demo\dist\server.js:31873:72)
at createElement (F:\git\ng-universal-demo\dist\server.js:9067:23)
at createViewNodes (F:\git\ng-universal-demo\dist\server.js:11533:44)
at createRootView (F:\git\ng-universal-demo\dist\server.js:11480:5)
at Object.createProdRootView [as createRootView] (F:\git\ng-universal-demo\dist\server.js:12049:12)
at ComponentFactory_.create (F:\git\ng-universal-demo\dist\server.js:9485:46)
at ApplicationRef_.bootstrap (F:\git\ng-universal-demo\dist\server.js:4862:57)
at F:\git\ng-universal-demo\dist\server.js:4657:89
at Array.forEach (native)
at PlatformRef_.moduleDoBootstrap (F:\git\ng-universal-demo\dist\server.js:4657:42)
at F:\git\ng-universal-demo\dist\server.js:4620:27
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59567:26)
at Object.onInvoke (F:\git\ng-universal-demo\dist\server.js:4017:37)
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59566:32)
at Zone.run (F:\git\ng-universal-demo\dist\server.js:59359:43)
Unhandled Promise rejection: document is not defined ; Zone: ; Task: Promise.then ; Value: { ReferenceError: document is not defined
at DefaultDomRenderer2.selectRootElement (F:\git\ng-universal-demo\dist\server.js:31873:72)
at createElement (F:\git\ng-universal-demo\dist\server.js:9067:23)
at createViewNodes (F:\git\ng-universal-demo\dist\server.js:11533:44)
at createRootView (F:\git\ng-universal-demo\dist\server.js:11480:5)
at Object.createProdRootView [as createRootView] (F:\git\ng-universal-demo\dist\server.js:12049:12)
at ComponentFactory.create (F:\git\ng-universal-demo\dist\server.js:9485:46)
at ApplicationRef_.bootstrap (F:\git\ng-universal-demo\dist\server.js:4862:57)
at F:\git\ng-universal-demo\dist\server.js:4657:89
at Array.forEach (native)
at PlatformRef_._moduleDoBootstrap (F:\git\ng-universal-demo\dist\server.js:4657:42)
at F:\git\ng-universal-demo\dist\server.js:4620:27
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59567:26)
at Object.onInvoke (F:\git\ng-universal-demo\dist\server.js:4017:37)
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59566:32)
at Zone.run (F:\git\ng-universal-demo\dist\server.js:59359:43)
__zone_symbol__currentTask:
ZoneTask {
zone:
Zone {
_properties: {},
parent: null,
name: '',
zoneDelegate: [Object] },
runCount: 0,
zoneDelegates: null,
state: 'notScheduled',
type: 'microTask',
source: 'Promise.then',
data: undefined,
scheduleFn: undefined,
cancelFn: null,
callback: [Function],
invoke: [Function] } } ReferenceError: document is not defined
at DefaultDomRenderer2.selectRootElement (F:\git\ng-universal-demo\dist\server.js:31873:72)
at createElement (F:\git\ng-universal-demo\dist\server.js:9067:23)
at createViewNodes (F:\git\ng-universal-demo\dist\server.js:11533:44)
at createRootView (F:\git\ng-universal-demo\dist\server.js:11480:5)
at Object.createProdRootView [as createRootView] (F:\git\ng-universal-demo\dist\server.js:12049:12)
at ComponentFactory.create (F:\git\ng-universal-demo\dist\server.js:9485:46)
at ApplicationRef.bootstrap (F:\git\ng-universal-demo\dist\server.js:4862:57)
at F:\git\ng-universal-demo\dist\server.js:4657:89
at Array.forEach (native)
at PlatformRef.moduleDoBootstrap (F:\git\ng-universal-demo\dist\server.js:4657:42)
at F:\git\ng-universal-demo\dist\server.js:4620:27
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59567:26)
at Object.onInvoke (F:\git\ng-universal-demo\dist\server.js:4017:37)
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59566:32)
at Zone.run (F:\git\ng-universal-demo\dist\server.js:59359:43)
{ Error: Uncaught (in promise): ReferenceError: document is not defined
ReferenceError: document is not defined
at DefaultDomRenderer2.selectRootElement (F:\git\ng-universal-demo\dist\server.js:31873:72)
at createElement (F:\git\ng-universal-demo\dist\server.js:9067:23)
at createViewNodes (F:\git\ng-universal-demo\dist\server.js:11533:44)
at createRootView (F:\git\ng-universal-demo\dist\server.js:11480:5)
at Object.createProdRootView [as createRootView] (F:\git\ng-universal-demo\dist\server.js:12049:12)
at ComponentFactory.create (F:\git\ng-universal-demo\dist\server.js:9485:46)
at ApplicationRef.bootstrap (F:\git\ng-universal-demo\dist\server.js:4862:57)
at F:\git\ng-universal-demo\dist\server.js:4657:89
at Array.forEach (native)
at PlatformRef.moduleDoBootstrap (F:\git\ng-universal-demo\dist\server.js:4657:42)
at F:\git\ng-universal-demo\dist\server.js:4620:27
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59567:26)
at Object.onInvoke (F:\git\ng-universal-demo\dist\server.js:4017:37)
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59566:32)
at Zone.run (F:\git\ng-universal-demo\dist\server.js:59359:43)
at resolvePromise (F:\git\ng-universal-demo\dist\server.js:59898:31) []
at resolvePromise (F:\git\ng-universal-demo\dist\server.js:59869:17) []
at F:\git\ng-universal-demo\dist\server.js:59946:17 []
at Zone.runTask (F:\git\ng-universal-demo\dist\server.js:59399:47) [ => ]
at drainMicroTaskQueue (F:\git\ng-universal-demo\dist\server.js:59779:35) []
at ZoneTask.invoke (F:\git\ng-universal-demo\dist\server.js:59657:25) []
at data.args.(anonymous function) (F:\git\ng-universal-demo\dist\server.js:60752:25) []
at FSReqWrap.oncomplete (fs.js:114:15) []
zone_symbol__error:
{ Error: Uncaught (in promise): ReferenceError: document is not defined
ReferenceError: document is not defined
at DefaultDomRenderer2.selectRootElement (F:\git\ng-universal-demo\dist\server.js:31873:72)
at createElement (F:\git\ng-universal-demo\dist\server.js:9067:23)
at createViewNodes (F:\git\ng-universal-demo\dist\server.js:11533:44)
at createRootView (F:\git\ng-universal-demo\dist\server.js:11480:5)
at Object.createProdRootView [as createRootView] (F:\git\ng-universal-demo\dist\server.js:12049:12)
at ComponentFactory.create (F:\git\ng-universal-demo\dist\server.js:9485:46)
at ApplicationRef.bootstrap (F:\git\ng-universal-demo\dist\server.js:4862:57)
at F:\git\ng-universal-demo\dist\server.js:4657:89
at Array.forEach (native)
at PlatformRef._moduleDoBootstrap (F:\git\ng-universal-demo\dist\server.js:4657:42)
at F:\git\ng-universal-demo\dist\server.js:4620:27
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59567:26)
at Object.onInvoke (F:\git\ng-universal-demo\dist\server.js:4017:37)
at ZoneDelegate.invoke (F:\git\ng-universal-demo\dist\server.js:59566:32)
at Zone.run (F:\git\ng-universal-demo\dist\server.js:59359:43)
at resolvePromise (F:\git\ng-universal-demo\dist\server.js:59898:31) []
at resolvePromise (F:\git\ng-universal-demo\dist\server.js:59869:17) []
at F:\git\ng-universal-demo\dist\server.js:59946:17 []
at Zone.runTask (F:\git\ng-universal-demo\dist\server.js:59399:47) [ => ]
at drainMicroTaskQueue (F:\git\ng-universal-demo\dist\server.js:59779:35) []
at ZoneTask.invoke (F:\git\ng-universal-demo\dist\server.js:59657:25) []
at data.args.(anonymous function) (F:\git\ng-universal-demo\dist\server.js:60752:25) []
at FSReqWrap.oncomplete (fs.js:114:15) []
Expected behavior
When i use animations in HTML, it will have no influence on SSR.
Minimal reproduction of the problem with instructions
Language: [TypeScript 2.2.1]
Node (for AoT issues):
node --version
= v7.7.1The text was updated successfully, but these errors were encountered: