Skip to content

Commit

Permalink
fix: fix devtools not sending new events if an error occured
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 16, 2021
1 parent 16f0e11 commit c333f40
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/devtools/src/useDevToolsBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit c333f40

Please sign in to comment.