Commit b4c933d
promises: refactor rejection handling
Remove the unnecessary microTasksTickObject for scheduling microtasks
and instead use TickInfo to keep track of whether promise rejections
exist that need to be emitted. Consequently allow the microtasks to
execute on average fewer times, in more predictable manner than
previously.
Simplify unhandled & handled rejection tracking to do more in C++ to
avoid needing to expose additional info in JS.
When new unhandledRejections are emitted within an unhandledRejection
handler, allow the event loop to proceed first instead. This means
that if the end-user code handles all promise rejections on nextTick,
rejections within unhandledRejection now won't spiral into an infinite
loop.
PR-URL: #18207
Fixes: #17913
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>1 parent 1be5e33 commit b4c933dCopy full SHA for b4c933d
File tree
Expand file treeCollapse file tree
7 files changed
+143
-157
lines changedOpen diff view settings
Filter options
- lib/internal/process
- src
- test
- message
- parallel
Expand file treeCollapse file tree
7 files changed
+143
-157
lines changedOpen diff view settings
Collapse file
lib/internal/process/next_tick.js
Copy file name to clipboardExpand all lines: lib/internal/process/next_tick.js+4-29Lines changed: 4 additions & 29 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
9 | 9 | |
10 | 10 | |
11 | 11 | |
12 | | - |
| 12 | + |
13 | 13 | |
14 | 14 | |
15 | 15 | |
| ||
30 | 30 | |
31 | 31 | |
32 | 32 | |
| 33 | + |
33 | 34 | |
34 | 35 | |
35 | 36 | |
| ||
58 | 59 | |
59 | 60 | |
60 | 61 | |
61 | | - |
62 | | - |
63 | 62 | |
64 | 63 | |
65 | 64 | |
66 | 65 | |
67 | 66 | |
68 | 67 | |
69 | 68 | |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | 69 | |
95 | 70 | |
96 | 71 | |
| ||
118 | 93 | |
119 | 94 | |
120 | 95 | |
121 | | - |
122 | | - |
| 96 | + |
| 97 | + |
123 | 98 | |
124 | 99 | |
125 | 100 | |
|
Collapse file
lib/internal/process/promises.js
Copy file name to clipboardExpand all lines: lib/internal/process/promises.js+86-100Lines changed: 86 additions & 100 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
2 | 2 | |
3 | 3 | |
4 | 4 | |
5 | | - |
6 | | - |
7 | | - |
| 5 | + |
8 | 6 | |
9 | | - |
| 7 | + |
| 8 | + |
10 | 9 | |
11 | | - |
| 10 | + |
| 11 | + |
| 12 | + |
12 | 13 | |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
| 14 | + |
20 | 15 | |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
28 | 21 | |
| 22 | + |
| 23 | + |
| 24 | + |
29 | 25 | |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
34 | 40 | |
| 41 | + |
| 42 | + |
35 | 43 | |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
59 | 51 | |
| 52 | + |
| 53 | + |
60 | 54 | |
61 | 55 | |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
73 | 66 | |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
74 | 73 | |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
98 | 83 | |
| 84 | + |
99 | 85 | |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
114 | 91 | |
115 | | - |
116 | 92 | |
117 | 93 | |
118 | | - |
119 | | - |
120 | | - |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
121 | 108 | |
122 | | - |
123 | | - |
| 109 | + |
124 | 110 | |
Collapse file
+8Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
264 | 264 | |
265 | 265 | |
266 | 266 | |
| 267 | + |
| 268 | + |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
| 273 | + |
| 274 | + |
267 | 275 | |
268 | 276 | |
269 | 277 | |
|
Collapse file
+6-1Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
295 | 295 | |
296 | 296 | |
297 | 297 | |
298 | | - |
| 298 | + |
| 299 | + |
299 | 300 | |
300 | 301 | |
301 | 302 | |
| ||
484 | 485 | |
485 | 486 | |
486 | 487 | |
| 488 | + |
| 489 | + |
| 490 | + |
487 | 491 | |
488 | 492 | |
489 | 493 | |
490 | 494 | |
491 | 495 | |
492 | 496 | |
493 | 497 | |
| 498 | + |
494 | 499 | |
495 | 500 | |
496 | 501 | |
|
0 commit comments