Skip to content

Commit

Permalink
Suppress unplug errors (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed Nov 20, 2022
1 parent 831794a commit c2c99d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/CroctProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest.mock(
...jest.requireActual('./ssr-polyfills'),
croct: {
plug: jest.fn(),
unplug: jest.fn(),
unplug: jest.fn().mockResolvedValue(undefined),
},
}),
);
Expand Down Expand Up @@ -82,4 +82,12 @@ describe('<CroctProvider />', () => {

expect(croct.unplug).toHaveBeenCalled();
});

it('should ignore errors on unmount', () => {
jest.mocked(croct.unplug).mockRejectedValue(new Error('foo'));

const {unmount} = render(<CroctProvider appId="00000000-0000-0000-0000-000000000000" />);

unmount();
});
});
4 changes: 3 additions & 1 deletion src/CroctProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export const CroctProvider: FunctionComponent<CroctProviderProps> = (props): Rea
croct.plug(initialConfiguration.current);

return () => {
croct.unplug();
croct.unplug().catch(() => {
// Suppress errors.
});
};
},
[],
Expand Down

0 comments on commit c2c99d5

Please sign in to comment.