Skip to content

Commit

Permalink
feat: keep alive when dispatch fails with 401 (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
williazz committed May 7, 2024
1 parent 34ce323 commit b9823bd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
2 changes: 1 addition & 1 deletion src/dispatch/Dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Dispatch {
private dispatchTimerId: number | undefined;
private buildClient: ClientBuilder;
private config: Config;
private disableCodes = ['401', '403', '404'];
private disableCodes = ['403', '404'];

constructor(
region: string,
Expand Down
30 changes: 0 additions & 30 deletions src/dispatch/__tests__/Dispatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,36 +479,6 @@ describe('Dispatch tests', () => {
expect((dispatch as unknown as any).enabled).toBe(true);
});

test('when a fetch request is rejected with 401 then dispatch is disabled', async () => {
// Init
(DataPlaneClient as any).mockImplementationOnce(() => ({
sendFetch: () => Promise.reject(new Error('401'))
}));

const eventCache: EventCache =
Utils.createDefaultEventCacheWithEvents();

const dispatch = new Dispatch(
Utils.AWS_RUM_REGION,
Utils.AWS_RUM_ENDPOINT,
eventCache,
{
...DEFAULT_CONFIG,
...{ dispatchInterval: Utils.AUTO_DISPATCH_OFF, retries: 0 }
}
);
dispatch.setAwsCredentials(Utils.createAwsCredentials());

// Run
eventCache.recordEvent('com.amazon.rum.event1', {});

// Assert
await expect(dispatch.dispatchFetch()).rejects.toEqual(
new Error('401')
);
expect((dispatch as unknown as any).enabled).toBe(false);
});

test('when a fetch request is rejected with 403 then dispatch is disabled', async () => {
// Init
(DataPlaneClient as any).mockImplementationOnce(() => ({
Expand Down

0 comments on commit b9823bd

Please sign in to comment.