From a88c61de3d1ffe9f355d24a26a2f28e1c9b45bfc Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 28 May 2025 13:50:46 +0200 Subject: [PATCH] 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. --- ext/node/polyfills/domain.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/node/polyfills/domain.ts b/ext/node/polyfills/domain.ts index daa613ede0..ebcc2a8c6f 100644 --- a/ext/node/polyfills/domain.ts +++ b/ext/node/polyfills/domain.ts @@ -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); }