From df4d7fbec037b966298707d9b93bab3765072f1a Mon Sep 17 00:00:00 2001 From: Priyansh Garg Date: Mon, 6 Jan 2025 12:25:31 +0530 Subject: [PATCH] Fix `.perform()` command node promise getting resolve early. (#4348) --- lib/api/client-commands/perform.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/api/client-commands/perform.js b/lib/api/client-commands/perform.js index 15d3c66b4c..f81f0b816e 100644 --- a/lib/api/client-commands/perform.js +++ b/lib/api/client-commands/perform.js @@ -62,9 +62,13 @@ class Perform extends EventEmitter { return true; } + static get avoidPrematureParentNodeResolution() { + return true; + } + command(callback = function() {}) { let doneCallback; - let asyncHookTimeout = this.client.settings.globals.asyncHookTimeout; + const asyncHookTimeout = this.client.settings.globals.asyncHookTimeout; this.timeoutId = setTimeout(() => { this.emit('error', new Error(`Timeout while waiting (${asyncHookTimeout}ms) for the .perform() command callback to be called.`)); @@ -99,7 +103,7 @@ class Perform extends EventEmitter { }; } else { doneCallback = () => { - let args = [(result) => { + const args = [(result) => { clearTimeout(this.timeoutId); this.emit('complete', result); }];