-
Notifications
You must be signed in to change notification settings - Fork 60
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
Native Node.js fetch fails with attempting DELETE requests #506
Comments
I don't recall the exact reason, but I remember that there was a weird problem with some of GitHub's REST APIs when the |
Forgot to add — I did attempt to hit that |
It looks like this is affecting other places too - see octokit/rest.js#190. Would it be practical to just set the body to an empty string? |
…T`/`HEAD` requests with no body Currently, `DELETE` requests without a body don't work on the latest Node.js version, v18, because we try to set `content-length: 0` which is not allowed by the native `fetch` implementation which is included. It throws an error with the `UND_ERR_REQ_CONTENT_LENGTH_MISMATCH` code. This stops manually setting that `content-length: 0` header for `DELETE` requests - and also `PUT`, `POST` and `PATCH` requests, given that it doesn't actually seem to be required. I've tested this against the GitHub API with Node.js v18 and v17, and both work as expected, with the GitHub API also accepting the request. Fixes octokit/request.js#506.
…` requests with no body Currently, `DELETE` requests without a body don't work on the latest Node.js version, v18, because we try to set `content-length: 0` which is not allowed by the native `fetch` implementation which is included in Node. It throws an error with the `UND_ERR_REQ_CONTENT_LENGTH_MISMATCH` code. This stops manually setting that `content-length: 0` header for `DELETE` requests. I've tested this against the GitHub API with Node.js v18 and v17, and both work as expected, with the GitHub API also accepting the request. As part of this PR, I've also added some new tests covering what happens with different HTTP methods. Fixes octokit/request.js#506.
…` requests with no body (#354) Currently, `DELETE` requests without a body don't work on the latest Node.js version, v18, because we try to set `content-length: 0` which is not allowed by the native `fetch` implementation which is included in Node. It throws an error with the `UND_ERR_REQ_CONTENT_LENGTH_MISMATCH` code. This stops manually setting that `content-length: 0` header for `DELETE` requests. I've tested this against the GitHub API with Node.js v18 and v17, and both work as expected, with the GitHub API also accepting the request. As part of this PR, I've also added some new tests covering what happens with different HTTP methods. Fixes octokit/request.js#506.
@rdmurphy can you confirm that the problems is resolved for you via |
Hello! This possibly overlaps with
@octokit/endpoint
— we noticed today after updating to the latest version of@octokit/rest
(v19
) that any API requests that we make that result in aDELETE
request (in our case it's delete a label) now fail when they are ran using Node v18. We think we tracked it down to how@octokit/request
now opts into using the native Fetch API.It appears that
node-fetch
andundici-fetch
(AKA native Node.js fetch) feel differently aboutDELETE
requests that setcontent-length: 0
(which happens via@octokit/endpoint
) without adding abody
.node-fetch
allows it to happen,undici-fetch
throws an error with theUND_ERR_REQ_CONTENT_LENGTH_MISMATCH
code.The text was updated successfully, but these errors were encountered: