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

Load zone.js long-stack-trace in debug mode #2233

Closed
vicb opened this issue Sep 19, 2016 · 5 comments
Closed

Load zone.js long-stack-trace in debug mode #2233

vicb opened this issue Sep 19, 2016 · 5 comments
Labels
area: @angular-devkit/build-angular feature Issue that requests a new feature

Comments

@vicb
Copy link

vicb commented Sep 19, 2016

dist/long-stack-trace-zone.min.js should be loaded in the development environment to give more meaningful stack traces.

Without this script, only the last VM turn is logged. When this script is loaded the stack will contain all VM turns from the point the async operation was initiated.

note the script should be loaded after zone.js

/ref angular/angular#11722

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    n/a
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    angular-cli: 1.0.0-beta.14
    node: 6.6.0
    os: darwin x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.

add throw new Error('test') in any async code (ie a component constructor).
The stack trace is incomplete, only show the last sync chunk of code.

  1. The log given by the failure. Normally this include a stack trace and some
    more information.

see angular/angular#11722 for more info

@filipesilva
Copy link
Contributor

@vicb when should this be loaded? As soon as possible in the app or anywhere?

@chrisnicola
Copy link

In the Webpack guide it is loaded after zone.js using the DefinePlugin to determine if we are running in production mode. See the src/polyfills.ts file here: https://angular.io/docs/ts/latest/guide/webpack.html#!#development-configuration

However I have tested this and it does not fix the problem in angular/angular#11722

@vicb
Copy link
Author

vicb commented Sep 20, 2016

@filipesilva after zone.js

@filipesilva filipesilva added effort3: hard (weeks/months) command: build P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Oct 3, 2016
@filipesilva
Copy link
Contributor

According to further discussion in angular/angular#11722 (comment), it seems that importing 'zone.js/dist/long-stack-trace-zone' is not the solution.

I tried it myself with the suggested repro by @chrisnicola:

// src/app.module.ts
// ...
export class AppModule {
  constructor(){
    console.log((new Error("NgModule stack")).stack)
  }
}
// src/app.component.ts
// ...
export class AppComponent {
  constructor() {
    console.log((new Error("Component stack")).stack)
  }
}

The output was the same with and without the long stack trace. The NgModule stack follows sourcemaps but the Component stack does not.

app.module.ts:29 Error: NgModule stack
    at new AppModule (app.module.ts:29) [angular]
    at AppModuleInjector.createInternal (module.ngfactory.js:206) [angular]
    at AppModuleInjector.NgModuleInjector.create (ng_module_factory.js:133) [angular]
    at NgModuleFactory.create (ng_module_factory.js:101) [angular]
    at :4200/vendor.bundle.js:34058:61 [angular]
    at Object.onInvoke (ng_zone.js:271) [angular]
    at Zone.run (zone.js:113) [<root> => angular]
    at NgZone.run (ng_zone.js:140) [<root>]
    at PlatformRef_._bootstrapModuleFactoryWithZone (application_ref.js:351) [<root>]
    at :4200/vendor.bundle.js:34107:59 [<root>]
    at Zone.run (zone.js:113) [<root> => <root>]

app.component.ts:12 Error: Component stack
    at new AppComponent (http://localhost:4200/main.bundle.js:1970:22) [angular]
    at new Wrapper_AppComponent (/AppModule/AppComponent/wrapper.ngfactory.js:7:18) [angular]
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.createInternal (/AppModule/AppComponent/host.ngfactory.js:15:28) [angular]
    at CompiledTemplate.proxyViewClass.AppView.createHostView (http://localhost:4200/vendor.bundle.js:69133:21) [angular]
    at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (http://localhost:4200/vendor.bundle.js:69589:52) [angular]
    at ComponentFactory.create (http://localhost:4200/vendor.bundle.js:36411:25) [angular]
    at ApplicationRef_.bootstrap (http://localhost:4200/vendor.bundle.js:34305:57) [angular]
    at http://localhost:4200/vendor.bundle.js:34116:89 [angular]
    at Array.forEach (native) [angular]
    at PlatformRef_._moduleDoBootstrap (http://localhost:4200/vendor.bundle.js:34116:42) [angular]
    at http://localhost:4200/vendor.bundle.js:34068:27 [angular]
    at Object.onInvoke (http://localhost:4200/vendor.bundle.js:27603:37) [angular]

@filipesilva filipesilva self-assigned this May 22, 2017
@hansl hansl added feature Issue that requests a new feature and removed type: enhancement labels Jan 30, 2018
@filipesilva filipesilva removed effort3: hard (weeks/months) P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Feb 1, 2018
@mgechev mgechev closed this as completed Dec 17, 2018
@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/build-angular feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants