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

Parentheses in node file paths are filtered out #62

Open
mattwynne opened this issue Jul 19, 2021 · 0 comments · May be fixed by #82
Open

Parentheses in node file paths are filtered out #62

mattwynne opened this issue Jul 19, 2021 · 0 comments · May be fixed by #82

Comments

@mattwynne
Copy link
Contributor

mattwynne commented Jul 19, 2021

Expected Behavior

When parsing the stack for a file that happens to have parentheses in its name, I expected those parentheses to still be there when I got the parsed StackFrame object's fileName.

e.g.

path/to/my (top secret) project/file.js

remains as

path/to/my (top secret) project/file.js

Current Behavior

Parentheses are stripped out of the path.

e.g.

path/to/my (top secret) project/file.js

becomes

path/to/my top secret project/file.js`

Steps to Reproduce (for bugs)

I wrote a failing test for it that reproduces the problem, in a branch which you can see here.

Context

This has caused us some problems running Cucumber-JS's own tests if the developer's environment has parens in the path. See cucumber/cucumber-js#1735

Your Environment

  • stacktrace.js version: v2.0.2
  • Browser Name and version: n/a
  • Operating System and version (desktop or mobile): OSX 11.4

Possible Solution

If you want to submit a PR with a fix for this, you'll need to start by forking this repo. If you install the gh command-line tool, you can do that with:

$ gh repo fork stacktracejs/error-stack-parser

That should hopefully fork the repo to your GitHub account and then create a local clone of it.

In the new directory of the local clone, you can then create a branch, and pull in my commit with the failing test:

$ git checkout -b allow-parens-in-node-filename
$ git pull git@github.com:mattwynne/error-stack-parser.git allow-parens-in-node-filename

Try running the tests, and you should see one failing:

npm install
npm test
npm test

> error-stack-parser@2.0.6 test
> karma start karma.conf.js --single-run

19 07 2021 14:32:05.968:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
19 07 2021 14:32:05.971:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
19 07 2021 14:32:05.975:INFO [launcher]: Starting browser PhantomJS
19 07 2021 14:32:07.389:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket S7DEMBo_p_scyXL8AAAA with id 77822057
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR LOG: 'DEPRECATION:', 'Setting specFilter directly on Env is deprecated and will be removed in a future version of Jasmine, please use the specFilter option in `configure`'

  ErrorStackParser
    #parse
      ✓ should parse Safari 7 Error.stack
      ✓ should parse Safari 8 Error.stack
      ✓ should parse nested eval() from Safari 9
      ✓ should parse Firefox 31 Error.stack
      ✓ should parse nested eval() from Firefox 43
      ✓ should parse function names containing @ in Firefox 43 Error.stack
      ✓ should parse IE 10 Error stacks
      ✓ should parse Opera 11 Error messages
      ✓ should parse IE 11 Error stacks
      ✓ should parse stack traces with @ in the URL
      ✓ should parse Opera 25 Error stacks
      ✓ should parse stack traces with @ in the URL and the method
      ✓ should parse Opera 9.27 Error messages
      ✓ should parse Safari 6 Error.stack
      ✓ should not parse IE 9 Error
      ✓ should handle webpack eval stacks
      ✓ should handle spaces in Node.js stacks
      ✓ should parse nested eval() from Edge
      ✓ should handle newlines in Error stack messages
      ✓ should parse Opera 10 Error messages
      ✗ should handle parentheses in Node.js stacks
	Expected '/var/app/scratch/my project top secret/index.js' to equal '/var/app/scratch/my project (top secret)/index.js'.
	<Jasmine>
	spec/error-stack-parser-spec.js:237:52
	<Jasmine>

      ✓ should parse V8 Error.stack
      ✓ should parse error stacks with Constructors
      ✓ should parse V8 entries with no location
      ✓ should parse V8 Error.stack entries with port numbers
      ✓ should parse nested eval() from V8

PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 26 of 26 (1 FAILED) (0.35 secs / 0.313 secs)
TOTAL: 1 FAILED, 25 SUCCESS


1) should handle parentheses in Node.js stacks
     ErrorStackParser #parse
     Expected '/var/app/scratch/my project top secret/index.js' to equal '/var/app/scratch/my project (top secret)/index.js'.
<Jasmine>
spec/error-stack-parser-spec.js:237:52
<Jasmine>

Now you just need to fiddle with the code until that test passes :)

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

Successfully merging a pull request may close this issue.

1 participant