Change of behaviour regarding micro tasks and `Nan::AsyncProgressWorkerBase`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 531
- Avg merge
- 21m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report names no repository file or minimal reproduction. Start by comparing Node.js 26.3.0 and 26.4.0 behavior around Nan::AsyncProgressWorkerBase::HandleOKCallback and the microtask queue, using the described raw V8 Promise resolution and mocha context if possible. Done means establishing whether the behavior change is intentional and identifying a reproducible expected outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100