Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding a chrome javascript stacktrace

I have a few questions regarding the following javascript stacktrace.

  1. Why are there two parts to the stacktrace: a first one in red at the top and a second one in black below?
  2. What does the first line beginning with at mean? i.e. at angular.js:63: why is it not referring to a function/method call like the other lines?
  3. How is it ordered? Do the lines at the bottom occur before the lines at the top?

javascript stacktrace

like image 613
balteo Avatar asked May 07 '15 11:05

balteo


2 Answers

  1. The bits in red are the exception/error message - in this case it looks like Angular has thrown an exception and as part of that exception it has added the contents of the stacktrace to the message, whilst the black bits are the stack trace that you'd get whenever the browser experiences an unhandled exception.
    1. The first line at states where the error occured - script name and line number - if you take a look at the source of angular.js at line 63 you will see the statement that threw the exception.
    2. It it's not referring to a function call as it is the statement that threw the exception. The only way to get to that statement is through a series of function calls, these are then shown in reverse order.
  2. Correct. For example the Scope.$apply function makes a call to Scope.$eval and Scope.$eval calls a function called callback, etc.

like image 87
phuzi Avatar answered Sep 18 '22 03:09

phuzi


Chrome uses v8 engine to work on JavaScript. So, I am quoting the following link for answer - https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi

  1. I am not sure about answer to this question.

  2. The first line tells us the location where the error occurred. With framework like angular, it could be deep inside the framework it need not be user code.

  3. Yes it is bottom up, i.e. from the point where the error occurred to upwards towards the caller, in this case to a jQuery event dispatch.

like image 38
Siva Senthil Avatar answered Sep 20 '22 03:09

Siva Senthil