evanw / node-source-map-support

Adds source map support to node.js (for stack traces)
MIT License
2.16k stars 222 forks source link

TypeError: Column must be greater than or equal to 0, got -62 #148

Open basarat opened 8 years ago

basarat commented 8 years ago

Stack trace :

TypeError: Column must be greater than or equal to 0, got -62
    at SourceMapConsumer_findMapping [as _findMapping] (D:\REPOS\alm\node_modules\source-map-support\node_modules\source-map\lib\source-map\source-map-consumer.js:281:15)
    at SourceMapConsumer_originalPositionFor [as originalPositionFor] (D:\REPOS\alm\node_modules\source-map-support\node_modules\source-map\lib\source-map\source-map-consumer.js:310:26)
    at mapSourcePosition (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:188:42)
    at wrapCallSite (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:327:20)
    at D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:362:26
    at Array.map (native)
    at Function.prepareStackTrace (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:361:24)
    at process.emit (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:411:51)
    at process._fatalException (node.js:237:26)

Tracked it down to https://github.com/evanw/node-source-map-support/blob/d8d1a8c14d35f15ac722a2d04b636cedf58f9fd3/source-map-support.js#L323-L325 moving it to -62.

More

The code I am working on is available here : https://github.com/alm-tools/alm/pull/181. However might be easiest to just ask me to log whatever you want and I'll send it throught :rose:

basarat commented 8 years ago

The basic issue is that the code hotfix for https://github.com/evanw/node-source-map-support/issues/36 assumes that there will be (function (exports, require, module, __filename, __dirname) { at the head of my file. That is not the case I am seeing in my invocation. Below I am logging out the line,column at https://github.com/evanw/node-source-map-support/blob/d8d1a8c14d35f15ac722a2d04b636cedf58f9fd3/source-map-support.js#L321 along with file at originalPositionFor

{ line: 1, column: 0 }
{ source: 'D:\\REPOS\\alm\\src\\tests\\testedTest.ts',
  line: 1,
  column: -62 }

My file starts with a call to describe hence line 1 column 0 :rose:

basarat commented 8 years ago

A PR fix for this exists : https://github.com/evanw/node-source-map-support/pull/138 :rose:

basarat commented 8 years ago

Didn't work with node 5.2.0. But works with 5.10.1.

Having two machines with different OSes / nodejs versions helped me figure that out :). I'll also try newer node version once they are more stable

RobinTail commented 1 year ago

The issue is still present in Jest

TypeError: Column must be greater than or equal to 0, got -32

=> Found "source-map-support@0.5.13"
info Reasons this module exists
   - "jest#@jest#core#jest-runner" depends on it
   - Hoisted from "jest#@jest#core#jest-runner#source-map-support"

UPD: I switched to vitest

chrisryanouellette commented 9 months ago

Also still experience this on jest version 29.7.0