Commit 6c249c0
committed
src: run native immediates during Environment cleanup
This can be necessary, because some parts of the Node.js code base
perform cleanup operations in the Immediate callbacks, e.g. HTTP/2.
This resolves flakiness in an HTTP/2 test that failed when a
`SetImmediate()` callback was not run or destroyed before the
`Environment` destructor started, because that callback held a
strong reference to the `Http2Session` object and the expectation
was that no such objects exist once the `Environment` constructor
starts.
Another, slightly more direct, alternative would have
been to clear the immediate queue rather than to run it. However,
this approach seems to make more sense as code generally assumes
that the `SetImmediate()` callback will always run; For example,
N-API uses an immediate callback to call buffer finalization
callbacks.
Unref’ed immediates are skipped, as the expectation is generally
that they may not run anyway.
Fixes: #30643
PR-URL: #30666
Refs: #30374
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent bea2501 commit 6c249c0Copy full SHA for 6c249c0
File tree
Expand file treeCollapse file tree
3 files changed
+30
-3
lines changedOpen diff view settings
Filter options
- src
- test/cctest
Expand file treeCollapse file tree
3 files changed
+30
-3
lines changedOpen diff view settings
Collapse file
+6-2Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
543 | 543 | |
544 | 544 | |
545 | 545 | |
| 546 | + |
| 547 | + |
546 | 548 | |
547 | 549 | |
548 | 550 | |
| ||
658 | 660 | |
659 | 661 | |
660 | 662 | |
661 | | - |
| 663 | + |
662 | 664 | |
663 | 665 | |
664 | 666 | |
| ||
675 | 677 | |
676 | 678 | |
677 | 679 | |
678 | | - |
| 680 | + |
| 681 | + |
| 682 | + |
679 | 683 | |
680 | 684 | |
681 | 685 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1417 | 1417 | |
1418 | 1418 | |
1419 | 1419 | |
1420 | | - |
| 1420 | + |
1421 | 1421 | |
1422 | 1422 | |
1423 | 1423 | |
|
Collapse file
test/cctest/test_environment.cc
Copy file name to clipboardExpand all lines: test/cctest/test_environment.cc+23Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
185 | 185 | |
186 | 186 | |
187 | 187 | |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
0 commit comments