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

CLI no longer provides location of error #351

Closed
woodyrew opened this issue Jun 5, 2017 · 1 comment · Fixed by #360
Closed

CLI no longer provides location of error #351

woodyrew opened this issue Jun 5, 2017 · 1 comment · Fixed by #360
Labels

Comments

@woodyrew
Copy link

woodyrew commented Jun 5, 2017

The CLI behaviour has changed between node v6 and v7.

Node v6 with trace (-t) option - Error and location:

$ `npm bin`/js-yaml -t src/index.md
YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 7, column 12:
    description: "Enterprise Content Management ... 
               ^
    at generateError (...

Node v7 with trace (-t) option - No useful information:

$ `npm bin`/js-yaml -t src/index.md
Error
    at generateError (...

Node v7 with compact (-c) option - Error only:

`npm bin`/js-yaml -c src/index.md
YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key

I assume this is due to Node no longer providing the same level of detail for errors?
Is there a way to get the location of the error again in v7?

@puzrin puzrin added the bug label Jun 5, 2017
@puzrin
Copy link
Member

puzrin commented Jun 5, 2017

Interesting. I don't use CLI and don't track what happens there.

Seems to be a bug.

not-an-aardvark added a commit to not-an-aardvark/js-yaml that referenced this issue Jul 30, 2017
Starting in Node 7, stack traces are computed eagerly when using Error.captureStackTrace [1]. As a result, the `message` and `name` properties of an error will not be included in the `stack` property if they are set after calling `Error.captureStackTrace`. As a workaround, set the properties before calling `Error.captureStackTrace`.

Note that this change in Node was reverted in V8 a few days ago [2], but it will probably be awhile until that fix appears in a Node release.

[1] https://chromium.googlesource.com/v8/v8.git/+/4feafee9d9741259e8ec3882fb61935a235ecc54
[2] https://chromium.googlesource.com/v8/v8.git/+/989d7b96f8352b502e2ede62e0b105e143d03837
puzrin pushed a commit that referenced this issue Jul 30, 2017
Starting in Node 7, stack traces are computed eagerly when using Error.captureStackTrace [1]. As a result, the `message` and `name` properties of an error will not be included in the `stack` property if they are set after calling `Error.captureStackTrace`. As a workaround, set the properties before calling `Error.captureStackTrace`.

Note that this change in Node was reverted in V8 a few days ago [2], but it will probably be awhile until that fix appears in a Node release.

[1] https://chromium.googlesource.com/v8/v8.git/+/4feafee9d9741259e8ec3882fb61935a235ecc54
[2] https://chromium.googlesource.com/v8/v8.git/+/989d7b96f8352b502e2ede62e0b105e143d03837
minj added a commit to minj/js-yaml that referenced this issue Apr 28, 2018
* master: (58 commits)
  Check for leading newlines when determining if block indentation indicator is needed (nodeca#404)
  Add property based tests to assess load reverses dump (nodeca#398)
  3.11.0 released
  Browser files rebuild
  Dumper: fix negative integers in bin/octal/hex formats, close nodeca#399
  support es6 arrow functions, fixes nodeca#389 (nodeca#393)
  Fix typo in README.md (nodeca#373)
  3.10.0 released
  Browser files rebuild
  Add test for astrals dump
  Combine surrogate pairs into one escape sequence when encoding. (nodeca#369)
  Fix condenseFlow for objects (nodeca#371)
  correct spelling mistake (nodeca#367)
  More meaningful error for loader (nodeca#361)
  Fix typo and format code. (nodeca#365)
  3.9.1 released
  Browser files rebuild
  Ensure stack is present for custom errors (fixes nodeca#351) (nodeca#360)
  3.9.0 released
  Browser files rebuild
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants