Skip to content

Commit b9823bd

Browse files
authored
feat: keep alive when dispatch fails with 401 (#551)
1 parent 34ce323 commit b9823bd

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

src/dispatch/Dispatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Dispatch {
3838
private dispatchTimerId: number | undefined;
3939
private buildClient: ClientBuilder;
4040
private config: Config;
41-
private disableCodes = ['401', '403', '404'];
41+
private disableCodes = ['403', '404'];
4242

4343
constructor(
4444
region: string,

src/dispatch/__tests__/Dispatch.test.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,36 +479,6 @@ describe('Dispatch tests', () => {
479479
expect((dispatch as unknown as any).enabled).toBe(true);
480480
});
481481

482-
test('when a fetch request is rejected with 401 then dispatch is disabled', async () => {
483-
// Init
484-
(DataPlaneClient as any).mockImplementationOnce(() => ({
485-
sendFetch: () => Promise.reject(new Error('401'))
486-
}));
487-
488-
const eventCache: EventCache =
489-
Utils.createDefaultEventCacheWithEvents();
490-
491-
const dispatch = new Dispatch(
492-
Utils.AWS_RUM_REGION,
493-
Utils.AWS_RUM_ENDPOINT,
494-
eventCache,
495-
{
496-
...DEFAULT_CONFIG,
497-
...{ dispatchInterval: Utils.AUTO_DISPATCH_OFF, retries: 0 }
498-
}
499-
);
500-
dispatch.setAwsCredentials(Utils.createAwsCredentials());
501-
502-
// Run
503-
eventCache.recordEvent('com.amazon.rum.event1', {});
504-
505-
// Assert
506-
await expect(dispatch.dispatchFetch()).rejects.toEqual(
507-
new Error('401')
508-
);
509-
expect((dispatch as unknown as any).enabled).toBe(false);
510-
});
511-
512482
test('when a fetch request is rejected with 403 then dispatch is disabled', async () => {
513483
// Init
514484
(DataPlaneClient as any).mockImplementationOnce(() => ({

0 commit comments

Comments
 (0)