Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

long-stack-trace zone breaks SourceMaps on stack traces #661

Closed
tbosch opened this issue Mar 6, 2017 · 2 comments
Closed

long-stack-trace zone breaks SourceMaps on stack traces #661

tbosch opened this issue Mar 6, 2017 · 2 comments

Comments

@tbosch
Copy link

tbosch commented Mar 6, 2017

Looks like the extra line in the stack trace breaks source maps (e.g. ------------- Elapsed: 4137 ms; At: Mon Mar 06 2017 11:00:38 GMT-0800 (PST) ------------- ).

This does not work (which is used by long-stack-trace zone)

var e = new Error();
e.stack = `at ErrorComponent.createError (http://localhost:8000/all/playground/src/sourcemap/index.js:21:64) [angular]
    at Object.eval [as handleEvent] (http://localhost:8000/nggen/ExampleModule/ErrorComponent.ngfactory.js:25:26) [angular]
    at handleEvent (http://localhost:8000/all/@angular/core/src/view/view.js:126:41) [angular]
    at callWithDebugContext (http://localhost:8000/all/@angular/core/src/view/services.js:428:25) [angular]
    at Object.debugHandleEvent [as handleEvent] (http://localhost:8000/all/@angular/core/src/view/services.js:134:12) [angular]
    at Object.dispatchEvent (http://localhost:8000/all/@angular/core/src/view/util.js:85:29) [angular]
    at http://localhost:8000/all/@angular/core/src/view/element.js:184:45 [angular]
    at HTMLButtonElement.<anonymous> (http://localhost:8000/all/@angular/platform-browser/src/dom/dom_renderer.js:60:36) [angular]
    at Object.onInvokeTask (http://localhost:8000/all/@angular/core/src/zone/ng_zone.js:230:37) [angular]
    at ZoneDelegate.invokeTask (http://localhost:8000/all/playground/vendor/zone.js:261:40) [angular]
    at Zone.runTask (http://localhost:8000/all/playground/vendor/zone.js:151:47) [<root> => angular]
    at HTMLButtonElement.ZoneTask.invoke (http://localhost:8000/all/playground/vendor/zone.js:332:33) [<root>]
  -------------   Elapsed: 4137 ms; At: Mon Mar 06 2017 11:00:38 GMT-0800 (PST)   -------------  
    at getStacktraceWithUncaughtError (http://localhost:8000/all/playground/vendor/long-stack-trace-zone.js:33:12) [angular]
    at new LongStackTrace (http://localhost:8000/all/playground/vendor/long-stack-trace-zone.js:27:22) [angular]
    at Object.onScheduleTask (http://localhost:8000/all/playground/vendor/long-stack-trace-zone.js:83:18) [angular]
`;
console.error(e);

This works:

var e = new Error();
e.stack = `at ErrorComponent.createError (http://localhost:8000/all/playground/src/sourcemap/index.js:21:64) [angular]
    at Object.eval [as handleEvent] (http://localhost:8000/nggen/ExampleModule/ErrorComponent.ngfactory.js:25:26) [angular]
    at handleEvent (http://localhost:8000/all/@angular/core/src/view/view.js:126:41) [angular]
    at callWithDebugContext (http://localhost:8000/all/@angular/core/src/view/services.js:428:25) [angular]
    at Object.debugHandleEvent [as handleEvent] (http://localhost:8000/all/@angular/core/src/view/services.js:134:12) [angular]
    at Object.dispatchEvent (http://localhost:8000/all/@angular/core/src/view/util.js:85:29) [angular]
    at http://localhost:8000/all/@angular/core/src/view/element.js:184:45 [angular]
    at HTMLButtonElement.<anonymous> (http://localhost:8000/all/@angular/platform-browser/src/dom/dom_renderer.js:60:36) [angular]
    at Object.onInvokeTask (http://localhost:8000/all/@angular/core/src/zone/ng_zone.js:230:37) [angular]
    at ZoneDelegate.invokeTask (http://localhost:8000/all/playground/vendor/zone.js:261:40) [angular]
    at BREAK =============== 500 ms elapse  ===== (http://localhost:8000/path:1:2)
    at HTMLButtonElement.ZoneTask.invoke (http://localhost:8000/all/playground/vendor/zone.js:332:33) [<root>]
    at getStacktraceWithUncaughtError (http://localhost:8000/all/playground/vendor/long-stack-trace-zone.js:33:12) [angular]
(http://localhost:8000/all/playground/vendor/zone.js:332:33) [<root>]
`;
console.error(e);
tbosch added a commit to tbosch/angular that referenced this issue Mar 8, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * $ng/<module type>/module.ngfactory.js
  * $ng/<module type>/<comp type>.ngfactory.js
  * $ng/<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 9, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * $ng/<module type>/module.ngfactory.js
  * $ng/<module type>/<comp type>.ngfactory.js
  * $ng/<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 9, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * $ng/<module type>/module.ngfactory.js
  * $ng/<module type>/<comp type>.ngfactory.js
  * $ng/<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 10, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * $ng/<module type>/module.ngfactory.js
  * $ng/<module type>/<comp type>.ngfactory.js
  * $ng/<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 10, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * $ng/<module type>/module.ngfactory.js
  * $ng/<module type>/<comp type>.ngfactory.js
  * $ng/<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 10, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * $ng/<module type>/module.ngfactory.js
  * $ng/<module type>/<comp type>.ngfactory.js
  * $ng/<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 11, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
tbosch added a commit to tbosch/angular that referenced this issue Mar 13, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
chuckjaz pushed a commit to angular/angular that referenced this issue Mar 14, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
@JiaLiPassion
Copy link
Collaborator

@tbosch , I would like to look into this issue, based on the angular/angular#15185, the source map will not be correct when SyntaxError, so I just modify the html template with some wrong syntax , so I can reproduce? If you can provide a reproduce repository, it will help, thank you.

SamVerschueren pushed a commit to SamVerschueren/angular that referenced this issue Mar 18, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
asnowwolf pushed a commit to asnowwolf/angular that referenced this issue Aug 11, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
juleskremer pushed a commit to juleskremer/angular that referenced this issue Aug 28, 2017
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see angular/zone.js#661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
@JiaLiPassion
Copy link
Collaborator

close for not be able to reproduce.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants