Skip to content

Commit 6e98880

Browse files
committed
add KickNextTick back
revert f1488bb
1 parent 6542755 commit 6e98880

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

src/env.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,27 @@ void Environment::PrintSyncTrace() const {
6464
fflush(stderr);
6565
}
6666

67+
68+
bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) {
69+
TickInfo* info = tick_info();
70+
71+
if (scope->in_makecallback()) {
72+
return true;
73+
}
74+
75+
if (info->length() == 0) {
76+
isolate()->RunMicrotasks();
77+
}
78+
79+
if (info->length() == 0) {
80+
info->set_index(0);
81+
return true;
82+
}
83+
84+
Local<Value> ret =
85+
tick_callback_function()->Call(process_object(), 0, nullptr);
86+
87+
return !ret.IsEmpty();
88+
}
89+
6790
} // namespace node

src/env.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ class Environment {
467467

468468
inline int64_t get_async_wrap_uid();
469469

470+
bool KickNextTick(AsyncCallbackScope* scope);
471+
470472
inline uint32_t* heap_statistics_buffer() const;
471473
inline void set_heap_statistics_buffer(uint32_t* pointer);
472474

src/node.cc

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,23 +1257,7 @@ Local<Value> MakeCallback(Environment* env,
12571257
}
12581258
}
12591259

1260-
if (callback_scope.in_makecallback()) {
1261-
return ret;
1262-
}
1263-
1264-
Environment::TickInfo* tick_info = env->tick_info();
1265-
1266-
if (tick_info->length() == 0) {
1267-
env->isolate()->RunMicrotasks();
1268-
}
1269-
1270-
Local<Object> process = env->process_object();
1271-
1272-
if (tick_info->length() == 0) {
1273-
tick_info->set_index(0);
1274-
}
1275-
1276-
if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
1260+
if (!env->KickNextTick(&callback_scope)) {
12771261
return Undefined(env->isolate());
12781262
}
12791263

0 commit comments

Comments
 (0)