I have noticed a significant change of behaviour that seems to have occurred between Node.js 26.3.0 and Node.js 26.4.0 when using Nan::AsyncProgressWorkerBase that does not call JavaScript in HandleOKCallback.
I have a manual Promise resolution using raw V8 calls that goes something like this:
void MyWorker::HandleOKCallback() {
Nan::HandleScope scope;
auto context = Nan::GetCurrentContext();
// This comes from a persistent reference
v8::Local<v8::Promise::Resolver> resolver = Nan::New(*resolver_handle);
resolver->Resolve(context, this->ProduceRVal()).FromJust();
}
Since at least Node.js 12 and until Node.js 26.4.0 this code would result in the micro tasks queue being called after this function running the JS handlers of the promise.
Node.js 26.4.0 and later do not always call it, leaving the promise hanging in the air until something else calls it.
A simple fix is to simply call it manually, adding:
context->GetMicrotaskQueue()->PerformCheckpoint(isolate_);
I do not have a minimal repro and it might be difficult to do it since there are many other reasons why the micro tasks might get executed. In my case it happens only with mocha.
I am not very sure if a module should be calling the micro tasks directly and whether this change was intended or not.
I have noticed a significant change of behaviour that seems to have occurred between Node.js 26.3.0 and Node.js 26.4.0 when using
Nan::AsyncProgressWorkerBasethat does not call JavaScript inHandleOKCallback.I have a manual
Promiseresolution using raw V8 calls that goes something like this:Since at least Node.js 12 and until Node.js 26.4.0 this code would result in the micro tasks queue being called after this function running the JS handlers of the promise.
Node.js 26.4.0 and later do not always call it, leaving the promise hanging in the air until something else calls it.
A simple fix is to simply call it manually, adding:
context->GetMicrotaskQueue()->PerformCheckpoint(isolate_);I do not have a minimal repro and it might be difficult to do it since there are many other reasons why the micro tasks might get executed. In my case it happens only with
mocha.I am not very sure if a module should be calling the micro tasks directly and whether this change was intended or not.