legendecas
82b1b55122
process: add api to enable source-maps programmatically
...
Add `process.setSourceMapsEnabled` to enable
source-maps programmatically.
PR-URL: https://github.com/nodejs/node/pull/39085
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-07-15 19:45:16 +08:00
Gus Caplan
17821703cc
errors: remove eager stack generation for node errors
...
PR-URL: https://github.com/nodejs/node/pull/39182
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-07-07 20:50:57 -05:00
bcoe
c5cc3d4a8b
errors: don't rekey on primitive type
...
If an error is thrown before a module is loaded, we attempt to cache
source map against error object, rather than module object. We
can't do this if the error is a primitive type
Fixes #38945
PR-URL: https://github.com/nodejs/node/pull/39025
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-06-21 18:35:34 -07:00
Rich Trott
2f95941296
lib: remove semicolon in preparation for babel/eslint-parser update
...
eslint-babel-plugin will complain about this semicolon when we update
to 7.14.15.
PR-URL: https://github.com/nodejs/node/pull/39094
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-06-21 14:03:25 -07:00
bcoe
88d9268d08
errors: align source-map stacks with spec
...
Reformat stack traces when --enable-source-maps flag is set to format
more likely to fit https://github.com/tc39/proposal-error-stacks
PR-URL: https://github.com/nodejs/node/pull/37252
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ian Sutherland <ian@iansutherland.ca >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2021-02-12 14:09:35 -08:00
Antoine du Hamel
e2b954b149
lib: refactor source_map to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36733
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-13 20:59:39 +01:00
Antoine du Hamel
3a44f37ef6
lib: refactor source_map to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/36734
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com >
2021-01-13 15:50:53 +01:00
Antoine du Hamel
bd6f2303f4
lib: add primordials.SafeStringIterator
...
PR-URL: https://github.com/nodejs/node/pull/36526
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-25 18:11:23 +00:00
Antoine du Hamel
0a5969c62a
lib: make safe primordials safe to iterate
...
PR-URL: https://github.com/nodejs/node/pull/36391
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-12-15 13:25:55 +00:00
bcoe
09fd8f13c8
errors: display original symbol name
...
If symbol names array has been populated in source map, include
original symbol name in error message.
Fixes https://github.com/nodejs/node/issues/35325
PR-URL: https://github.com/nodejs/node/pull/36042
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2020-12-01 07:23:56 -08:00
bcoe
8fa90358d7
module: refactor to use iterable-weak-map
...
Using an iterable WeakMap (a data-structure that uses WeakRef and
WeakMap), we are able to: stop relying on Module._cache to
serialize source maps; stop requiring an error object when calling
findSourceMap().
PR-URL: https://github.com/nodejs/node/pull/35915
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-11-06 12:47:23 -08:00
Antoine du Hamel
e6e6070364
errors: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/35944
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-05 22:55:34 +00:00
bcoe
26fcdb655e
errors: do not call resolve on URLs with schemes
...
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.
Refs: https://github.com/nodejs/node/issues/35325
PR-URL: https://github.com/nodejs/node/pull/35903
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-11-02 16:28:08 -08:00
sapics
ee3416b055
lib: replace http to https of comment link urls
...
PR-URL: https://github.com/nodejs/node/pull/34158
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-07-06 07:03:08 -07:00
Brian White
c24b74a7ab
lib: improve debuglog() performance
...
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 17:24:43 -04:00
bcoe
458677f5ef
errors: print original exception context
...
When --enable-source-maps is set, the error context displayed
above the stack trace now shows original source rather than
transpiled.
PR-URL: https://github.com/nodejs/node/pull/33491
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2020-05-24 22:03:34 -07:00
Luigi Pinca
b533fb3508
tools: enable no-else-return lint rule
...
Refs: https://github.com/nodejs/node/pull/32644
Refs: https://github.com/nodejs/node/pull/32662
PR-URL: https://github.com/nodejs/node/pull/32667
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-05-16 06:42:16 +02:00
himself65
1bbd679adc
lib: replace Array to ArrayIsArray by primordials
...
PR-URL: https://github.com/nodejs/node/pull/32258
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-03-30 10:22:52 +02:00
bcoe
fb26b13623
module: port source map sort logic from chromium
...
Digging in to the delta between V8's source map library, and chromium's
the most significant difference that jumped out at me was that we were
failing to sort generated columns. Since negative offsets are not
restricted in the spec, this can lead to bugs.
fixes : #31286
PR-URL: https://github.com/nodejs/node/pull/31927
Fixes: https://github.com/nodejs/node/issues/31286
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-27 17:33:56 -08:00
Justin Ridgewell
f2ec64fbcf
lib: delete dead code in SourceMap
...
This seems to be a leftover from the chromium project. Nothing uses
`#reverseMappingsBySourceURL`, so constructing it isn't necessary.
PR-URL: https://github.com/nodejs/node/pull/31512
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-28 15:29:33 +00:00
Justin Ridgewell
0214b90308
process: fix two overflow cases in SourceMap VLQ decoding
...
These both have to do with extremely large numbers, so it's unlikely to
cause a problem in practice. Still, correctness.
First, encoding `-2147483648` in VLQ returns the value `"B"`. When
decoding, we get the value `1` after reading the base64. We then check
if the first bit is set (it is) to see if we should negate it, then we
shift all bits right once. Now, `value` will be `0` and `negate` will
be `true`. So, we'd return `-0`. Which is a bug! `-0` isn't
`-2147483648`, and we've broken a round trip.
Second, encoding any number with the 31st bit set, we'd return the
opposite sign. Let's use `1073741824`. Encoding, we get `"ggggggC"`.
When decoding, we get the value `-2147483648` after reading the base64.
Notice, it's already negative (the 32nd bit is set, because the 31st was
set and we shifted everything left once). We'd then check the first bit
(it's not) and shift right. But we used `>>`, which does not shift the
sign bit. We actually wanted `>>>`, which will. Because of that bug, we
get back `-1073741824` instead of the positive `1073741824`. It's even
worse if the 32nd and 31st bits are set, `-1610612736` becomes
`536870912` after a round trip.
I recently fixed the same two bugs in Closure Compiler:
https://github.com/google/closure-compiler/commit/584418eb
PR-URL: https://github.com/nodejs/node/pull/31490
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2020-01-26 17:03:39 -08:00
bcoe
521b2224c3
module: add API for interacting with source maps
...
PR-URL: https://github.com/nodejs/node/pull/31132
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-14 12:39:06 -08:00
Sebastien Ahkrin
9085c03806
lib: replace Map global by the primordials
...
PR-URL: https://github.com/nodejs/node/pull/31155
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 14:56:52 -08:00
Sebastien Ahkrin
c9b93e2344
lib: replace use of Error with primordials
...
PR-URL: https://github.com/nodejs/node/pull/31163
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 14:50:18 -08:00
Sebastien Ahkrin
f509aaa7fa
lib: replace WeakMap global by the primordials
...
PR-URL: https://github.com/nodejs/node/pull/31158
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 12:28:29 -08:00
bcoe
9cdda60081
errors: support prepareSourceMap with source-maps
...
Adds support for Error.prepareStackTrace override, when
--enable-source-maps is set.
PR-URL: https://github.com/nodejs/node/pull/31143
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-01-02 15:07:38 -08:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
...
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.
PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2019-11-25 10:28:15 +01:00
Anna Henningsen
f17e414dc4
process: make source map getter resistant against prototype tampering
...
Since this code runs during process and Worker shutdown, it should not
call user-provided code and thereby e.g. provide a way to break out of
`worker.terminate()`.
PR-URL: https://github.com/nodejs/node/pull/30228
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-11-05 20:55:54 +01:00
bcoe
4ca61f40fe
process: add lineLength to source-map-cache
...
Without the line lengths of in-memory transpiled source, it's not
possible to convert from byte ofsets to line/column offsets.
PR-URL: https://github.com/nodejs/node/pull/29863
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-10-13 18:58:21 -07:00
bcoe
e1e2f669f6
process: add source-map support to stack traces
...
PR-URL: https://github.com/nodejs/node/pull/29564
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-10-05 17:08:00 -07:00