Skip to content

Line and column number in stacktraces are not reliable. #607

Closed as not planned
@ammarahm-ed

Description

@ammarahm-ed

Line and column number in stack traces do not match with browser.

Take this code as an example

const a = {
  b: {
      C: {
          extend: function extend() {
              console.log(new Error().stack); // 5
          }

      }

  }
}
a.b.C.extend({ // 12
  init: function() {
    console.log("init");
  }
}); // 16

QuickJs:

at extend (/data/data/com.tns.testapplication/files/app/MyActivity.js:5:31)
at <anonymous> (/data/data/com.tns.testapplication/files/app/MyActivity.js:16:1) < call site

Browser:

extend@debugger eval code:5:27
@debugger eval code:12:7
  1. Browser records column/line at opening of function call while quickjs records it at closing line/column.
  2. Similarly browser records line/column for new call at the start of new keyword while quickjs records it from the Class name. Incorrect column number in stack traces repro #236

I found a related PR that might address this issue: #406

Another example:

a.b.C.extend();

results in this stack in quickjs:

at extend (/data/data/com.tns.testapplication/files/app/MyActivity.js:5:31)
at <anonymous> (/data/data/com.tns.testapplication/files/app/MyActivity.js:12:1) < call site

while in browser it is consistent always at the start of function call.

Another one:

a.b.C.extend( // 12
// 13
); // 14

quickjs stack gives 14:1 as column number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions