From c333f4086ea04c879fdd46ccc206d3faf84fabca Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Fri, 16 Jul 2021 10:20:23 +0200 Subject: [PATCH] fix: fix devtools not sending new events if an error occured --- packages/devtools/src/useDevToolsBase.tsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/devtools/src/useDevToolsBase.tsx b/packages/devtools/src/useDevToolsBase.tsx index 94ad1727..0a72482c 100644 --- a/packages/devtools/src/useDevToolsBase.tsx +++ b/packages/devtools/src/useDevToolsBase.tsx @@ -103,15 +103,20 @@ export default function useDevToolsBase( const send = React.useCallback((data: ActionData) => { // We need to make sure that our callbacks executed in the same order - pendingPromiseRef.current = pendingPromiseRef.current.then(async () => { - if (data.stack) { - const stack = await symbolicate(data.stack); + // So we add check if the last promise is settled before sending the next one + pendingPromiseRef.current = pendingPromiseRef.current + .catch(() => { + // Ignore any errors from the last promise + }) + .then(async () => { + if (data.stack) { + const stack = await symbolicate(data.stack); - callbackRef.current({ ...data, stack }); - } else { - callbackRef.current(data); - } - }); + callbackRef.current({ ...data, stack }); + } else { + callbackRef.current(data); + } + }); }, []); React.useEffect(() => {