Skip to content

NoopZone throws errors when Zone.js is not included #23428

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
robwormald opened this issue Apr 18, 2018 · 13 comments
Closed

NoopZone throws errors when Zone.js is not included #23428

robwormald opened this issue Apr 18, 2018 · 13 comments
Labels
area: core Issues related to the framework runtime freq1: low regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Milestone

Comments

@robwormald
Copy link
Contributor

I'm submitting a...

[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

NgZone throws a ReferenceError: Zone is not defined error when { ngZone: 'noop' } is used to bootstrap a module.

Expected behavior

Using the noop ngZone should not require Zone.js to be loaded.

I believe the regression was introduced here : #16863

We should probably have some kind of integration test for this.

@robwormald robwormald added regression Indicates than the issue relates to something that worked in a previous version area: core Issues related to the framework runtime labels Apr 18, 2018
@ngbot ngbot bot added this to the needsTriage milestone Apr 18, 2018
@JiaLiPassion
Copy link
Contributor

JiaLiPassion commented Apr 18, 2018

@robwormald , I would like to fix this one and add integration test for it. And I just created a new project with angular/cli and

  • remove zone.js from polyfill.ts.
  • bootstrap with ngZone: 'noop'.

everything work file, could you provide a reproduce repo? thank you.

@robwormald
Copy link
Contributor Author

@JiaLiPassion see https://stackblitz.com/edit/angular-branw3?file=app%2Fapp.component.ts - I think this will only surface on v6+?

@JiaLiPassion
Copy link
Contributor

@robwormald , yes, you are right, thank you for the reproduce link.

@JiaLiPassion
Copy link
Contributor

@robwormald , I have created a PR #23452 to fix this one, please review, thank you.

JiaLiPassion added a commit to JiaLiPassion/angular that referenced this issue Apr 19, 2018
JiaLiPassion added a commit to JiaLiPassion/angular that referenced this issue Apr 19, 2018
JiaLiPassion added a commit to JiaLiPassion/angular that referenced this issue Apr 19, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Apr 24, 2018
@oliverdavidt
Copy link

@JiaLiPassion Is there any workaround for this error while we wait for your PR to merged?

@JiaLiPassion
Copy link
Contributor

@oliverdavidt , I believe you can define this line in polifills.ts to avoid the error for now.

(window as any)['Zone'] = {
  current: {
    get: function() {}
  }
};

@oliverdavidt
Copy link

@JiaLiPassion That worked. Thank you.

@mohammadhfh
Copy link

what should we do in angular ssr in server.ts?

@alexzuza
Copy link
Contributor

Another workaround could be:

providers: [{ provide: Testability, useValue: null }]

@maylortaylor
Copy link

(window as any)['Zone'] = { current: { get: function() {} } };

does it matter where this goes on the polyfill.ts file? Is it best on top or bottom of the file?

@JiaLiPassion
Copy link
Contributor

@maylortaylor, you can put this code anywhere in polyfill.ts.

@alxhub
Copy link
Member

alxhub commented Feb 26, 2019

Fixed by @kara in ee12e725.

@alxhub alxhub closed this as completed Feb 26, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime freq1: low regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Projects
None yet
Development

No branches or pull requests

7 participants