src: make AtExit() callbacks run in reverse order · nodejs/node@2e729f2 · GitHub
Skip to content

Commit 2e729f2

Browse files
addaleaxMylesBorins
authored andcommitted
src: make AtExit() callbacks run in reverse order
This makes the actual behaviour match the documented (and arguably the correct) behaviour. PR-URL: #30230 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 569f797 commit 2e729f2

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

doc/api/addons.md

Lines changed: 1 addition & 1 deletion

src/env.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void Environment::RunAtExitCallbacks() {
636636
}
637637

638638
void Environment::AtExit(void (*cb)(void* arg), void* arg) {
639-
at_exit_functions_.push_back(ExitCallback{cb, arg});
639+
at_exit_functions_.push_front(ExitCallback{cb, arg});
640640
}
641641

642642
void Environment::RunAndClearNativeImmediates() {

test/cctest/test_environment.cc

Lines changed: 29 additions & 0 deletions

0 commit comments

Comments
 (0)