Commit 67b854d
repl: remove dependency on domain module
Replace the domain-based error handling with AsyncLocalStorage and
setUncaughtExceptionCaptureCallback. This removes the REPL's dependency
on the deprecated domain module while preserving all existing behavior:
- Synchronous errors during eval are caught and displayed
- Async errors (setTimeout, promises, etc.) are caught via the
uncaught exception capture callback
- Top-level await errors are caught and displayed
- The REPL continues operating after errors
- Multiple REPL instances can coexist with errors routed correctly
Changes:
- Use AsyncLocalStorage to track which REPL instance owns an async
context, replacing domain's automatic async tracking
- Add setupExceptionCapture() to install
setUncaughtExceptionCaptureCallback for catching async errors and
routing them to the correct REPL
- Extract error handling logic into REPLServer.prototype._handleError()
- Wrap eval execution in replContext.run() for async context tracking
- Update newListener protection to check AsyncLocalStorage context
- Throw ERR_INVALID_ARG_VALUE if options.domain is passed
PR-URL: #61227
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>1 parent 62d2cd4 commit 67b854dCopy full SHA for 67b854d
26 files changed
+417-289Lines changed: 417 additions & 289 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- doc/api
- lib
- internal
- bootstrap
- process
- test
- common
- fixtures
- parallel
- pummel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+46-2Lines changed: 46 additions & 2 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
736 | 736 | |
737 | 737 | |
738 | 738 | |
| 739 | + |
| 740 | + |
| 741 | + |
| 742 | + |
| 743 | + |
| 744 | + |
| 745 | + |
| 746 | + |
| 747 | + |
| 748 | + |
| 749 | + |
| 750 | + |
| 751 | + |
| 752 | + |
| 753 | + |
| 754 | + |
| 755 | + |
| 756 | + |
| 757 | + |
| 758 | + |
| 759 | + |
| 760 | + |
| 761 | + |
| 762 | + |
| 763 | + |
| 764 | + |
| 765 | + |
| 766 | + |
| 767 | + |
| 768 | + |
| 769 | + |
| 770 | + |
| 771 | + |
| 772 | + |
| 773 | + |
| 774 | + |
| 775 | + |
| 776 | + |
739 | 777 | |
740 | 778 | |
741 | 779 | |
| ||
4015 | 4053 | |
4016 | 4054 | |
4017 | 4055 | |
| 4056 | + |
| 4057 | + |
| 4058 | + |
| 4059 | + |
| 4060 | + |
4018 | 4061 | |
4019 | 4062 | |
4020 | 4063 | |
| ||
4034 | 4077 | |
4035 | 4078 | |
4036 | 4079 | |
4037 | | - |
4038 | | - |
| 4080 | + |
| 4081 | + |
4039 | 4082 | |
4040 | 4083 | |
4041 | 4084 | |
| ||
4567 | 4610 | |
4568 | 4611 | |
4569 | 4612 | |
| 4613 | + |
4570 | 4614 | |
4571 | 4615 | |
4572 | 4616 | |
|
Collapse file
+2-18Lines changed: 2 additions & 18 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | | - |
44 | 43 | |
45 | 44 | |
46 | 45 | |
47 | 46 | |
48 | 47 | |
49 | | - |
50 | | - |
51 | 48 | |
52 | 49 | |
53 | 50 | |
| ||
119 | 116 | |
120 | 117 | |
121 | 118 | |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
| 119 | + |
| 120 | + |
132 | 121 | |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | 122 | |
139 | 123 | |
140 | 124 | |
|
Collapse file
lib/internal/bootstrap/node.js
Copy file name to clipboardExpand all lines: lib/internal/bootstrap/node.js+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
307 | 307 | |
308 | 308 | |
309 | 309 | |
| 310 | + |
310 | 311 | |
311 | 312 | |
312 | 313 | |
| ||
319 | 320 | |
320 | 321 | |
321 | 322 | |
| 323 | + |
| 324 | + |
322 | 325 | |
323 | 326 | |
324 | 327 | |
|
Collapse file
lib/internal/process/execution.js
Copy file name to clipboardExpand all lines: lib/internal/process/execution.js+47-14Lines changed: 47 additions & 14 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | 2 | |
3 | 3 | |
| 4 | + |
4 | 5 | |
5 | 6 | |
6 | 7 | |
| ||
17 | 18 | |
18 | 19 | |
19 | 20 | |
| 21 | + |
20 | 22 | |
21 | 23 | |
22 | 24 | |
| ||
105 | 107 | |
106 | 108 | |
107 | 109 | |
108 | | - |
| 110 | + |
| 111 | + |
109 | 112 | |
110 | 113 | |
111 | 114 | |
112 | 115 | |
113 | 116 | |
114 | 117 | |
115 | | - |
116 | | - |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
117 | 122 | |
118 | 123 | |
119 | 124 | |
| ||
129 | 134 | |
130 | 135 | |
131 | 136 | |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
132 | 152 | |
133 | 153 | |
134 | 154 | |
| ||
154 | 174 | |
155 | 175 | |
156 | 176 | |
| 177 | + |
157 | 178 | |
158 | 179 | |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
167 | 201 | |
168 | | - |
169 | | - |
| 202 | + |
170 | 203 | |
171 | | - |
172 | 204 | |
173 | 205 | |
174 | 206 | |
| ||
477 | 509 | |
478 | 510 | |
479 | 511 | |
| 512 | + |
480 | 513 | |
481 | 514 | |
0 commit comments