diff --git a/utils.js b/utils.js index bc4eb7705..187ebfd0b 100644 --- a/utils.js +++ b/utils.js @@ -322,9 +322,15 @@ export class InjectionsHandler extends BasicHandler { if (!(original instanceof Function)) throw new Error(`Virtual function ${name}() is not available for ${object}`); - object[name] = function (...args) { - return injectedFunction.call(this, original, ...args); - }; + if (original.constructor.name === "AsyncFunction") { + object[name] = async function (...args) { + return injectedFunction.call(this, original, ...args); + }; + } else { + object[name] = function (...args) { + return injectedFunction.call(this, original, ...args); + }; + } return [object, name, original]; }