fix(ext/node): return values in node:domain (#29440)

When using Domain#bind, Domain#intercept, and Domain#run we were
invoking the callback but then not actually returning the value returned
from that callback.

This makes Gulp work with async functions as tasks.
This commit is contained in:
Luca Casonato 2025-05-28 13:50:46 +02:00 committed by GitHub
parent 32db2db121
commit a88c61de3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,7 +50,7 @@ export class Domain extends EventEmitter {
const self = this;
return function () {
try {
FunctionPrototypeApply(fn, null, ArrayPrototypeSlice(arguments));
return FunctionPrototypeApply(fn, null, ArrayPrototypeSlice(arguments));
} catch (e) {
FunctionPrototypeCall(emitError, self, e);
}
@ -65,7 +65,11 @@ export class Domain extends EventEmitter {
FunctionPrototypeCall(emitError, self, e);
} else {
try {
FunctionPrototypeApply(fn, null, ArrayPrototypeSlice(arguments, 1));
return FunctionPrototypeApply(
fn,
null,
ArrayPrototypeSlice(arguments, 1),
);
} catch (e) {
FunctionPrototypeCall(emitError, self, e);
}
@ -75,7 +79,7 @@ export class Domain extends EventEmitter {
run(fn) {
try {
fn();
return fn();
} catch (e) {
FunctionPrototypeCall(emitError, this, e);
}