Commit 4249276
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: #43875
Fixes: #43186
Fixes: #41541
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>1 parent 374b776 commit 4249276Copy full SHA for 4249276
File tree
Expand file treeCollapse file tree
18 files changed
+221
-87
lines changedOpen diff view settings
Filter options
- benchmark
- es
- fixtures
- lib/internal/source_map
- src
- test/message
Expand file treeCollapse file tree
18 files changed
+221
-87
lines changedOpen diff view settings
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
6 | 6 | |
7 | 7 | |
8 | 8 | |
| 9 | + |
9 | 10 | |
10 | 11 | |
11 | 12 | |
Collapse file
benchmark/es/error-stack.js
Copy file name to clipboard+34Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
Collapse file
benchmark/fixtures/simple-error-stack.js
Copy file name to clipboardExpand all lines: benchmark/fixtures/simple-error-stack.js+15Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
benchmark/fixtures/simple-error-stack.ts
Copy file name to clipboard+17Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
Collapse file
lib/internal/source_map/prepare_stack_trace.js
Copy file name to clipboardExpand all lines: lib/internal/source_map/prepare_stack_trace.js+26-18Lines changed: 26 additions & 18 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
25 | 25 | |
26 | 26 | |
27 | 27 | |
| 28 | + |
28 | 29 | |
29 | 30 | |
30 | 31 | |
| ||
53 | 54 | |
54 | 55 | |
55 | 56 | |
56 | | - |
57 | 57 | |
58 | 58 | |
59 | 59 | |
| ||
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | | - |
66 | 65 | |
67 | 66 | |
68 | | - |
69 | 67 | |
70 | 68 | |
71 | 69 | |
72 | | - |
| 70 | + |
73 | 71 | |
74 | 72 | |
75 | 73 | |
| ||
83 | 81 | |
84 | 82 | |
85 | 83 | |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | 84 | |
95 | 85 | |
96 | 86 | |
| ||
116 | 106 | |
117 | 107 | |
118 | 108 | |
119 | | - |
| 109 | + |
120 | 110 | |
121 | 111 | |
122 | 112 | |
| ||
155 | 145 | |
156 | 146 | |
157 | 147 | |
158 | | - |
| 148 | + |
159 | 149 | |
160 | 150 | |
161 | 151 | |
| ||
178 | 168 | |
179 | 169 | |
180 | 170 | |
181 | | - |
182 | | - |
183 | | - |
| 171 | + |
184 | 172 | |
185 | 173 | |
186 | 174 | |
187 | 175 | |
188 | 176 | |
189 | 177 | |
190 | | - |
| 178 | + |
191 | 179 | |
192 | 180 | |
| 181 | + |
| 182 | + |
193 | 183 | |
194 | 184 | |
195 | 185 | |
196 | 186 | |
197 | 187 | |
198 | 188 | |
| 189 | + |
| 190 | + |
199 | 191 | |
200 | 192 | |
201 | 193 | |
202 | 194 | |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
203 | 211 | |
204 | 212 | |
205 | 213 | |
Collapse file
lib/internal/source_map/source_map_cache.js
Copy file name to clipboardExpand all lines: lib/internal/source_map/source_map_cache.js+54-37Lines changed: 54 additions & 37 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
41 | 41 | |
42 | 42 | |
43 | 43 | |
| 44 | + |
| 45 | + |
44 | 46 | |
45 | 47 | |
46 | 48 | |
| ||
77 | 79 | |
78 | 80 | |
79 | 81 | |
80 | | - |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
81 | 98 | |
82 | 99 | |
83 | 100 | |
| ||
87 | 104 | |
88 | 105 | |
89 | 106 | |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
94 | 111 | |
95 | 112 | |
96 | 113 | |
| ||
99 | 116 | |
100 | 117 | |
101 | 118 | |
102 | | - |
| 119 | + |
| 120 | + |
103 | 121 | |
104 | 122 | |
105 | | - |
| 123 | + |
106 | 124 | |
107 | 125 | |
108 | | - |
109 | | - |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
110 | 133 | |
111 | 134 | |
112 | 135 | |
113 | | - |
| 136 | + |
114 | 137 | |
115 | 138 | |
116 | | - |
117 | | - |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
118 | 146 | |
119 | 147 | |
120 | 148 | |
| ||
123 | 151 | |
124 | 152 | |
125 | 153 | |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
| 154 | + |
| 155 | + |
131 | 156 | |
132 | 157 | |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | 158 | |
138 | | - |
| 159 | + |
139 | 160 | |
140 | 161 | |
141 | 162 | |
| ||
254 | 275 | |
255 | 276 | |
256 | 277 | |
257 | | - |
| 278 | + |
258 | 279 | |
259 | 280 | |
260 | 281 | |
261 | 282 | |
262 | 283 | |
263 | 284 | |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | | - |
276 | | - |
| 285 | + |
| 286 | + |
| 287 | + |
| 288 | + |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | + |
| 293 | + |
277 | 294 | |
278 | 295 | |
279 | 296 | |
280 | 297 | |
281 | 298 | |
282 | 299 | |
283 | | - |
| 300 | + |
284 | 301 | |
285 | 302 | |
286 | 303 | |
|
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
525 | 525 | |
526 | 526 | |
527 | 527 | |
| 528 | + |
528 | 529 | |
529 | 530 | |
530 | 531 | |
|
0 commit comments