feat(axios-to-whatwg-fetch): introduce #269
Conversation
|
omg please yes |
|
cc @nodejs/userland-migrations can I have first review on this one |
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
|
@JakobJingleheimer I tried to apply all of your proposal. But why the ci didn't ran ? |
|
It looks like CI did run? If not, was this whilst I was fiddling with the repo permissions? (I specifically told you on slack you'd temporarily have |
it's ran after the merge commit. idk what really happened but it's work now ! it's didn't help since I dunno why windows is doing windows thing |
JakobJingleheimer
left a comment
There was a problem hiding this comment.
Great tidy!
It's still missing handling for transformRequest, transformResponse, paramsSerializer, etc, which was the blocker before. It needs to either
- support them
- detect them and abort/fail the migration
Doing neither will result in broken userland code.
d1ae93f to
469e199
Compare
|
@JakobJingleheimer applied your proposal |
| 'transformRequest', | ||
| 'transformResponse', | ||
| 'paramsSerializer', | ||
| 'withCredentials', | ||
| 'timeout', | ||
| 'httpAgent', | ||
| 'httpsAgent', | ||
| 'validateStatus', | ||
| 'maxRedirects', | ||
| 'socketPath', | ||
| 'decompress', | ||
| 'maxContentLength', | ||
| 'maxBodyLength', | ||
| 'beforeRedirect', | ||
| 'cancelToken', | ||
| 'signal', |
There was a problem hiding this comment.
nit: for the grok
| 'transformRequest', | |
| 'transformResponse', | |
| 'paramsSerializer', | |
| 'withCredentials', | |
| 'timeout', | |
| 'httpAgent', | |
| 'httpsAgent', | |
| 'validateStatus', | |
| 'maxRedirects', | |
| 'socketPath', | |
| 'decompress', | |
| 'maxContentLength', | |
| 'maxBodyLength', | |
| 'beforeRedirect', | |
| 'cancelToken', | |
| 'signal', | |
| 'beforeRedirect', | |
| 'cancelToken', | |
| 'decompress', | |
| 'httpAgent', | |
| 'httpsAgent', | |
| 'maxBodyLength', | |
| 'maxContentLength', | |
| 'maxRedirects', | |
| 'paramsSerializer', | |
| 'signal', | |
| 'socketPath', | |
| 'timeout', | |
| 'transformRequest', | |
| 'transformResponse', | |
| 'validateStatus', | |
| 'withCredentials', |
| 'beforeRedirect', | ||
| 'cancelToken', | ||
| 'signal', | ||
| ]; |
There was a problem hiding this comment.
| ]; | |
| ] as const; |
| } | ||
|
|
||
| return { unsupported: false }; | ||
| }; |
There was a problem hiding this comment.
There could be more than one; I think it would be useful to report them all to the user. In that case, I think it would make sense to do something like
function getUnsupportedOptions(configNode?: SgNode<Js>): false | (typeof UNSUPPORTED_CONFIG_OPTIONS)[number][];| // if it's already a FormData or URLSearchParams instance, return as is | ||
| // we only check for common instantiation patterns here maybe add complex ones later |
There was a problem hiding this comment.
nit
| // if it's already a FormData or URLSearchParams instance, return as is | |
| // we only check for common instantiation patterns here maybe add complex ones later | |
| // if it's already a FormData or URLSearchParams instance, return as-is | |
| // we only check for common instantiation patterns here—maybe add complex ones later? |
| }, | ||
| }); | ||
|
|
||
| const axiosMethodUpdates: AxiosMethodUpdateConfig[] = [ |
There was a problem hiding this comment.
Better to use satisfies
| const axiosMethodUpdates: AxiosMethodUpdateConfig[] = [ | |
| const axiosMethodUpdates = [ |
| oldOptionsIndex: 1, | ||
| optionalOptionsArg: false, | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
| ]; | |
| ] satisfies AxiosMethodUpdateConfig[]; |
| const baseUpdates: { | ||
| oldBind: string; | ||
| replaceFn: BindingToReplace['replaceFn']; | ||
| supportDefaultAccess?: boolean; | ||
| }[] = [ |
There was a problem hiding this comment.
| const baseUpdates: { | |
| oldBind: string; | |
| replaceFn: BindingToReplace['replaceFn']; | |
| supportDefaultAccess?: boolean; | |
| }[] = [ | |
| const baseUpdates = [ |
| `; | ||
| }, | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
| ]; | |
| ] satisfies { | |
| oldBind: string; | |
| replaceFn: BindingToReplace['replaceFn']; | |
| supportDefaultAccess?: boolean; | |
| }[]; |
| return dedent.withOptions({ alignValues: true })` | ||
| fetch(${url}${options ? `, ${options}` : ''}) | ||
| .then(async (resp) => Object.assign(resp, { data: await resp.json() })) | ||
| .catch(() => null) | ||
| `; |
There was a problem hiding this comment.
nit: since this is dedented, can the indentation here be "proper"?
| return dedent.withOptions({ alignValues: true })` | |
| fetch(${url}${options ? `, ${options}` : ''}) | |
| .then(async (resp) => Object.assign(resp, { data: await resp.json() })) | |
| .catch(() => null) | |
| `; | |
| return dedent.withOptions({ alignValues: true })` | |
| fetch(${url}${options ? `, ${options}` : ''}) | |
| .then(async (resp) => Object.assign(resp, { data: await resp.json() })) | |
| .catch(() => null) | |
| `; |
| }, | ||
| }, | ||
| { | ||
| oldBind: '$.request', |
There was a problem hiding this comment.
Ohh 🤦 👍
I think still better to errorWithLocation (because something failed).
Related issue
close #191
info https://socket.dev/blog/axios-npm-package-compromised