legendecas
6bdc101c63
src,lib: retrieve parsed source map url from v8
...
V8 already parses the source map magic comments. Currently, only scripts
and functions expose the parsed source map URLs. It is unnecessary to
parse the source map magic comments again when the parsed information is
available.
PR-URL: https://github.com/nodejs/node/pull/44798
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2022-10-23 22:37:21 +08:00
Alan Agius
e6018e2864
lib: don't match sourceMappingURL in strings
...
Prior to this change `sourceMappingURL` in string where being matched
by the RegExp which caused sourcemaps not be loaded when using the
`--enable-source-maps` flag. This commit changes the RegExp to match
the last occurrence.
Fixes: https://github.com/nodejs/node/issues/44654
PR-URL: https://github.com/nodejs/node/pull/44658
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-09-26 00:11:18 +08:00
Chengzhong Wu
72df448d2a
lib: codify findSourceMap return value when not found
...
Return `undefined` when no source map is found for the given filename on
`findSourceMap`.
PR-URL: https://github.com/nodejs/node/pull/44397
Fixes: https://github.com/nodejs/node/issues/44391
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-08-27 23:13:53 +00:00
legendecas
0a2c910ae9
src,lib: print prinstine source when source map source not found
...
Print unmapped source lines when the source map source is not
found. Error stacks should be correctly mapped even when the
source is absent.
PR-URL: https://github.com/nodejs/node/pull/44052
Refs: https://github.com/nodejs/node/pull/44019
Reviewed-By: Ben Coe <bencoe@gmail.com >
2022-08-06 19:56:27 +08:00
legendecas
803a7b2b23
src,lib: print source map error source on demand
...
The source context is not prepended to the value of the `stack` property
when the source map is not enabled. Rather than prepending the error
source context to the value of the `stack` property unconditionally,
this patch aligns the behavior and only prints the source context when
the error is not handled by userland (e.g. fatal errors).
Also, this patch fixes that when source-map support is enabled, the
error source context is not pointing to where the error was thrown.
PR-URL: https://github.com/nodejs/node/pull/43875
Fixes: https://github.com/nodejs/node/issues/43186
Fixes: https://github.com/nodejs/node/issues/41541
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2022-07-28 08:09:30 +08:00
legendecas
02eb10b87b
lib,src: add source map support for global eval
...
Dynamic sources with FunctionConstructor is not supported yet as
V8 prepends lines to the sources which makes the stack line number
incorrect.
PR-URL: https://github.com/nodejs/node/pull/43428
Refs: https://github.com/nodejs/node/issues/43047
Reviewed-By: Ben Coe <bencoe@gmail.com >
2022-07-11 21:44:04 +08:00
Antoine du Hamel
a055337a02
lib: refactor to avoid unsafe regex primordials
...
PR-URL: https://github.com/nodejs/node/pull/43475
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2022-06-27 17:16:06 +02:00
Fabian Cook
154fa4132b
lib: source maps filter null prefix
...
Fixes: https://github.com/nodejs/node/issues/42417
PR-URL: https://github.com/nodejs/node/pull/42522
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-04-03 17:21:38 +01:00
Benjamin E. Coe
65b60b5676
errors: do not access .stack in debug
...
Refs: #41541
PR-URL: https://github.com/nodejs/node/pull/42096
Refs: https://github.com/nodejs/node/issues/41541
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Mestery <mestery@protonmail.com >
2022-02-25 21:20:51 +00:00
Mohammed Keyvanzadeh
4712472c0f
lib: refactor to use validateObject() validator
...
Use the `validateObject()` validator in source maps where appropriate.
PR-URL: https://github.com/nodejs/node/pull/41845
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-02-06 13:09:08 +00:00
Mohammed Keyvanzadeh
85eca3d2c7
lib: refactor source map stack trace prepare
...
• Make use of the logical OR operator (`||`) for better
readability.
• Remove unnecessary conditional and wrapping.
PR-URL: https://github.com/nodejs/node/pull/41698
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-01-29 22:01:55 +00:00
Rich Trott
290911b99a
lib: remove erroneous JSDoc entry
...
The entry contains incorrect parameters and duplicates the subsequent
constructor entry. Remove it.
(I'm not sure why this is being caught by the linter on my local machine
but not in CI.)
PR-URL: https://github.com/nodejs/node/pull/41604
Reviewed-By: Mestery <mestery@protonmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2022-01-21 14:37:44 -08:00
Rich Trott
0264f2395f
lib: remove spurious JSDoc entry
...
PR-URL: https://github.com/nodejs/node/pull/41240
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2021-12-21 23:19:51 +00:00
Rich Trott
1e8b296c58
lib,test,tools: use consistent JSDoc types
...
This could be in preparation of implementing the jsdoc/check-types
ESLint rule.
PR-URL: https://github.com/nodejs/node/pull/40989
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2021-11-29 06:48:00 +00:00
Rich Trott
492d767b6d
test: add semicolons for linter update
...
Add missing semicolons that will be flagged when we update
@babel/eslint-parser to 7.16.0.
PR-URL: https://github.com/nodejs/node/pull/40720
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-11-08 13:16:21 -08:00
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