From cff60209234271e6f45211b4453d0df32b0d1ede Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Fri, 1 Oct 2021 18:00:17 +0200 Subject: [PATCH 1/2] adjust condition --- src/utils/merge-config.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/utils/merge-config.ts b/src/utils/merge-config.ts index ec281a2cc..1d5a6fec3 100644 --- a/src/utils/merge-config.ts +++ b/src/utils/merge-config.ts @@ -8,15 +8,16 @@ export const mergeConfigs = ( // Need to create a new object to avoid mutating the original here. const v: Partial = mergeObjects(a, b) - if (!b) return v - - const { use: u1, fallback: f1 } = a - const { use: u2, fallback: f2 } = b - if (u1 && u2) { - v.use = u1.concat(u2) - } - if (f1 && f2) { - v.fallback = mergeObjects(f1, f2) + // If two configs are provided, merge their `use` and `fallback` options. + if (b) { + const { use: u1, fallback: f1 } = a + const { use: u2, fallback: f2 } = b + if (u1 && u2) { + v.use = u1.concat(u2) + } + if (f1 && f2) { + v.fallback = mergeObjects(f1, f2) + } } return v From 6adaef6a351eedb1527f984e5c112adc3819d5e9 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Fri, 1 Oct 2021 18:07:15 +0200 Subject: [PATCH 2/2] use .catch --- src/utils/mutate.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/mutate.ts b/src/utils/mutate.ts index 12e6396f4..924c5e291 100644 --- a/src/utils/mutate.ts +++ b/src/utils/mutate.ts @@ -53,11 +53,9 @@ export const internalMutate = async ( if (_data && isFunction((_data as Promise).then)) { // This means that the mutation is async, we need to check timestamps to // avoid race conditions. - try { - data = await _data - } catch (err) { + data = await (_data as Promise).catch(err => { error = err - } + }) // Check if other mutations have occurred since we've started this mutation. // If there's a race we don't update cache or broadcast the change,