From 927cbd1681f11ad7c410522114d1a6f2a20581f0 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Tue, 12 Mar 2019 12:16:54 +0100 Subject: [PATCH] Revert MicrotasksPolicy::kAuto --- src/addon.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/addon.cpp b/src/addon.cpp index 21ffccf..3793508 100644 --- a/src/addon.cpp +++ b/src/addon.cpp @@ -61,11 +61,21 @@ void Main(Local exports) { isolate = exports->GetIsolate(); /* We want this so that we can redefine process.nextTick to using the V8 native microtask queue */ - isolate->SetMicrotasksPolicy(MicrotasksPolicy::kAuto); + // todo: setting this might be crashing nodejs? + // isolate->SetMicrotasksPolicy(MicrotasksPolicy::kAuto); /* Integrate with existing libuv loop, we just pass a boolean basically */ uWS::Loop::get((void *) 1); + // instead, for now we call this manually like before: + uWS::Loop::get()->setPostHandler([](uWS::Loop *) { + isolate->RunMicrotasks(); + }); + + uWS::Loop::get()->setPreHandler([](uWS::Loop *) { + isolate->RunMicrotasks(); + }); + /* uWS namespace */ exports->Set(String::NewFromUtf8(isolate, "App"), FunctionTemplate::New(isolate, uWS_App)->GetFunction()); exports->Set(String::NewFromUtf8(isolate, "SSLApp"), FunctionTemplate::New(isolate, uWS_App)->GetFunction());