-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@slack/web-api: prep for next major release. bump min node to v18 #1667
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,20 +34,6 @@ describe('WebClient', function () { | |
assert.instanceOf(client, WebClient); | ||
assert.notExists(client.axios.defaults.headers.Authorization); | ||
}); | ||
it('should not modify global defaults in axios', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't feel like this test offers much value and since this PR moves from axios 0.x to 1.x, also not sure how much we should be testing the output of other packages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @filmaj As you can see, the context behind this unit test is #1037 This package had an issue polluting the global singleton instance of If investigation on how to properly maintain this test with axios 1.x could require our time and efforts, it's fine to delete the test anyways. Whenever we have something similar in the future, we can add tests again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems in the latest axios, no specific value is set for the HTTP POST default headers. This is also the case for 'common' HTTP all-verb headers. In v0.27.2 of axios, this was not the case: POST would set a default Therefore, I think this test can be safely removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking this! |
||
// https://github.com/slackapi/node-slack-sdk/issues/1037 | ||
const client = new WebClient(); | ||
|
||
const globalDefault = axios.defaults.headers.post['Content-Type']; | ||
// The axios.default's defaults should not be modified. | ||
// Specifically, defaults.headers.post should be kept as-is | ||
assert.exists(globalDefault); | ||
|
||
const instanceDefault = client.axios.defaults.headers.post['Content-Type']; | ||
// WebClient intentionally removes the default Content-Type | ||
// from the underlying AxiosInstance used for performing web API calls | ||
assert.notExists(instanceDefault) | ||
}); | ||
}); | ||
|
||
describe('Methods superclass', function () { | ||
|
@@ -149,7 +135,6 @@ describe('WebClient', function () { | |
assert.equal(error.code, ErrorCode.RequestError); | ||
assert.equal(error.original.config.timeout, timeoutOverride); | ||
assert.equal(error.original.isAxiosError, true); | ||
assert.equal(error.original.request.aborted, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In axios 1.0, this assertion no longer passes. Not sure how important that is. Let me know if you have opinions on that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any issues with the deletion |
||
done(); | ||
} catch (err) { | ||
done(err); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,13 @@ export function httpErrorFromResponse(response: AxiosResponse): WebAPIHTTPError | |
) as Partial<WebAPIHTTPError>; | ||
error.statusCode = response.status; | ||
error.statusMessage = response.statusText; | ||
error.headers = response.headers; | ||
const nonNullHeaders: Record<string, string> = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TypeScript made me do it 😄 |
||
Object.keys(response.headers).forEach((k) => { | ||
if (k && response.headers[k]) { | ||
nonNullHeaders[k] = response.headers[k]; | ||
} | ||
}); | ||
error.headers = nonNullHeaders; | ||
error.body = response.data; | ||
return (error as WebAPIHTTPError); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should they email [email protected] or [email protected]? other repos tell developers to email [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is
[email protected]