Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacktrace rewrite (sourceMap support) fails for absolute Windows paths #1097

Open
nikku opened this issue Jun 10, 2014 · 1 comment
Open

Comments

@nikku
Copy link

nikku commented Jun 10, 2014

The regex for attaching source locations in lib/reporter.js#L25 fails to match absolute Windows path.

The problem is that the regular expression matches drive letters in path such as C:/foo,js as as the path name. This leads to the stack trace below not being rewritten.

Error: intentional
    at http://localhost:9876/absoluteC:/foo.js?da39a3ee5e6b4b0d3255bfef95601890afd80709:17

We could make the used regular expression less restrictive by removing the \\: part from the path segment to fix the issue.

var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*\\/' +
                              '(base|absolute)' + // prefix
                              '([^\\?\\s\\]*)' + // path
                              '(\\?\\w*)?' +      // sha
                              '(\\:(\\d+))?' +    // line
                              '(\\:(\\d+))?' +    // column
                              '', 'g');`

This however this breaks the existing test case.

An additional test case for test/unit/reporter.spec.coffee that must must pass on Windows systems could be the following:

      it 'should rewrite absolute stack trace (Windows)', (done) ->

        formatError = m.createErrorFormatter '/some/base', emitter, MockSourceMapConsumer
        servedFiles = [new File('C:/b.js')]
        servedFiles[0].sourceMap = 'SOURCE MAP b.js'

        emitter.emit 'file_list_modified', q(served: servedFiles)

        scheduleNextTick ->
          ERROR = 'at http://localhost:123/base/C:/b.js:2:6'
          expect(formatError ERROR).to.equal 'at /some/base/b.js:2:6 <- C:/original/b.js:4:8\n'
          done()

Maybe I am mistaken but I believe a simple regex fix will not solve the issue across all platforms.

Give me the OK to rewrite the URL matching with some more sophisticated logic and I am happy to provide a pull request.

@rodgarcia
Copy link

I had this problem too. I had an encoded space in my path (%20). I renamed the file removing that code and now it works.

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

No branches or pull requests

3 participants