In the client, don't wait if the stub doesn't return a promise

This commit is contained in:
denihs
2022-10-25 09:23:27 -03:00
parent 57a8d036d0
commit d24bf3a797

View File

@@ -695,7 +695,14 @@ export class Connection {
invocation
);
try {
stubOptions.stubReturnValue = await stubInvocation();
const resultOrThenable = stubInvocation();
const isThenable =
resultOrThenable && typeof resultOrThenable.then === 'function';
if (isThenable) {
stubOptions.stubReturnValue = await resultOrThenable;
} else {
stubOptions.stubReturnValue = resultOrThenable;
}
} finally {
DDP._CurrentMethodInvocation._set(currentContext);
}