Skip to content

Commit

Permalink
fix: Revert "fix: Remove Axios config from errors (#22)"
Browse files Browse the repository at this point in the history
This reverts commit dbc3053
  • Loading branch information
gnarea committed Nov 17, 2020
1 parent dbc3053 commit 12985c2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
13 changes: 1 addition & 12 deletions src/lib/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ describe('deliverParcel', () => {
stubAxiosPost.mockResolvedValueOnce(stubResponse);

// @ts-ignore
jest.spyOn(axios, 'create').mockReturnValueOnce({
interceptors: { response: { use: jest.fn() } } as any,
post: stubAxiosPost,
});
jest.spyOn(axios, 'create').mockReturnValueOnce({ post: stubAxiosPost });
});

afterEach(() => {
Expand Down Expand Up @@ -85,14 +82,6 @@ describe('deliverParcel', () => {
expect(agent).toHaveProperty('keepAlive', true);
});

test('An interceptor that removes the request and response should be registered', async () => {
((axios.create as any) as jest.MockInstance<any, any>).mockRestore();

await expect(deliverParcel('https://httpstat.us/500', body)).rejects.not.toHaveProperty(
'jse_cause.config',
);
});

describe('POHTTP_TLS_REQUIRED', () => {
test('Non-TLS URLs should be refused if POHTTP_TLS_REQUIRED is undefined', async () => {
mockEnvVars({});
Expand Down
7 changes: 0 additions & 7 deletions src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export async function deliverParcel(
headers: { 'Content-Type': 'application/vnd.relaynet.parcel' },
httpsAgent: new https.Agent({ keepAlive: true }),
});

// Remove the request and response from the error cause to avoid filling the logs with
// unnecessary information. See: https://github.com/axios/axios/issues/2602
axiosInstance.interceptors.response.use(undefined, async error =>
Promise.reject(new Error(error.message)),
);

const response = await postRequest(targetNodeUrl, parcelSerialized, axiosInstance, axiosOptions);
if (response.status === 307 || response.status === 308) {
throw new PoHTTPError(`Reached maximum number of redirects (${axiosOptions.maxRedirects})`);
Expand Down

0 comments on commit 12985c2

Please sign in to comment.