From 7e985c8c132fd4d61fa48a67590350773a282b4e Mon Sep 17 00:00:00 2001 From: arturovt Date: Thu, 1 Feb 2024 15:02:27 +0200 Subject: [PATCH] chore: add `isPromise` change comments --- packages/store/src/internal/state-factory.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/store/src/internal/state-factory.ts b/packages/store/src/internal/state-factory.ts index 98f262051..0fec69340 100644 --- a/packages/store/src/internal/state-factory.ts +++ b/packages/store/src/internal/state-factory.ts @@ -278,6 +278,12 @@ export class StateFactory implements OnDestroy { try { let result = metadata.instance[actionMeta.fn](stateContext, action); + // We need to use `isPromise` instead of checking whether + // `result instanceof Promise`. In zone.js patched environments, `global.Promise` + // is the `ZoneAwarePromise`. Some APIs, which are likely not patched by zone.js + // for certain reasons, might not work with `instanceof`. For instance, the `fetch` + // response `json()` was returning a native promise (not a `ZoneAwarePromise`), + // causing this check to be falsy. if (ɵisPromise(result)) { result = from(result); }