Skip to content

[Q] Is it possible to get a stack trace with both line numbers and column numbers? #238

Closed

Description

@toyboot4e

About

Take this code as an example:

const f = () => {
throw new Error();
};

f();

Actual behavior

With quickjs-emscripten, the stack trace only shows line numbers:

    at f (example.js:3)
    at <eval> (example.js:6)

Desired behavior

In developer tool's console, it shows column numbers, too:

Uncaught Error
    at f (<anonymous>:2:7)
    at <anonymous>:5:1

How to reproduce

Here's repro.ts:

import { errors, getQuickJS } from "npm:quickjs-emscripten";

const QuickJS = await getQuickJS();
const vm = QuickJS.newContext();

const code = `
const f = () => {
throw new Error();
};

f();
`;
const evalResult = vm.evalCode(code, 'example.js');

try {
  const result = vm.unwrapResult(evalResult);
  throw new Error('unreachable!');
} catch (e: unknown) {
  if (e instanceof errors.QuickJSUnwrapError && e.cause && typeof e.cause === 'object' && 'stack' in e.cause) {
    console.log(e.cause.stack);
  }
}

The result is as follows. It only contains line numbers:

$ deno run repro.ts
    at f (example.js:3)
    at <eval> (example.js:6)

Activity

  1. justjake commented on Feb 16, 2026

    @justjake
    Owner

    I think in quickjs 2025-04-26, they started adding column numbers. Try updating to the latest quickjs-emscripten release which should include these changes. Although you may need to use a debug build or enable some debug features. Check quickjs.c for details.

  2. toyboot4e commented on Feb 16, 2026

    @toyboot4e
    Author

    Thank you. Now it shows column numbers, too:

        at f (example.js:3:16)
        at <eval> (example.js:6:2)
    

    Great!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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