-
Notifications
You must be signed in to change notification settings - Fork 347
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
🐛 Bug Report — Runtime APIs: workerd asserts on GET/HEAD request with 'Content-Length: 0' #1122
Comments
The error in question is thrown by the @mrbbot does Miniflare inject an ingress worker that handles requests before passing them on to the user's worker? If so I think this may be a bug in that ingress worker. |
For a little background here: The The Workers Runtime, as a compromise, permits bodied GET requests to proxy through, but does not allow a bodied GET to be constructed directly from JavaScript. This pass-through works even if you do It looks like miniflare might be deconstructing a |
Whilst prohibited by the `Request` API spec, `GET` requests are allowed to have bodies. If `Content-Length` or `Transfer-Encoding` are specified, `workerd` will give the request a (potentially empty) body. Passing a bodied-GET-request through to the `new Request()` constructor should throw, but `workerd` has special handling to allow this if a `Request` instance is passed. Miniflare was previously decomposing the request before passing it back to the `new Request()` constructor, defeating this detection. This change ensures we always pass full `Request` instances to the `new Request()` constructor in the entry worker. Closes cloudflare/workerd#1122
Hey! 👋 Yep, Miniflare has an ingress worker that does exactly that: request = new Request(url, {
method: request.method,
headers: request.headers,
cf: request.cf ?? env[CoreBindings.JSON_CF_BLOB],
redirect: request.redirect,
body: request.body,
}); The reason we decompose the request like this is so we can rewrite the URL, and add the fallback request = new Request(url, request);
if (request.cf === undefined) {
request = new Request(request, { cf: env[CoreBindings.JSON_CF_BLOB] });
} Something sneaky with Anyways, put a fix up here cloudflare/miniflare#677. Thanks for the explanation. 👍 |
Whilst prohibited by the `Request` API spec, `GET` requests are allowed to have bodies. If `Content-Length` or `Transfer-Encoding` are specified, `workerd` will give the request a (potentially empty) body. Passing a bodied-GET-request through to the `new Request()` constructor should throw, but `workerd` has special handling to allow this if a `Request` instance is passed. Miniflare was previously decomposing the request before passing it back to the `new Request()` constructor, defeating this detection. This change ensures we always pass full `Request` instances to the `new Request()` constructor in the entry worker. Closes cloudflare/workerd#1122
Yep, invoking the |
Thanks for the quick response all, and great to see the quick patch upstream! For anyone running into this before the next miniflare release (I see the patch hasn't landed in master yet): I've put a Node proxy in front of my local workers that stripped off the header to workaround this:
|
Whilst prohibited by the `Request` API spec, `GET` requests are allowed to have bodies. If `Content-Length` or `Transfer-Encoding` are specified, `workerd` will give the request a (potentially empty) body. Passing a bodied-GET-request through to the `new Request()` constructor should throw, but `workerd` has special handling to allow this if a `Request` instance is passed. Miniflare was previously decomposing the request before passing it back to the `new Request()` constructor, defeating this detection. This change ensures we always pass full `Request` instances to the `new Request()` constructor in the entry worker. Closes cloudflare/workerd#1122
Whilst prohibited by the `Request` API spec, `GET` requests are allowed to have bodies. If `Content-Length` or `Transfer-Encoding` are specified, `workerd` will give the request a (potentially empty) body. Passing a bodied-GET-request through to the `new Request()` constructor should throw, but `workerd` has special handling to allow this if a `Request` instance is passed. Miniflare was previously decomposing the request before passing it back to the `new Request()` constructor, defeating this detection. This change ensures we always pass full `Request` instances to the `new Request()` constructor in the entry worker. Closes cloudflare/workerd#1122
Whilst prohibited by the `Request` API spec, `GET` requests are allowed to have bodies. If `Content-Length` or `Transfer-Encoding` are specified, `workerd` will give the request a (potentially empty) body. Passing a bodied-GET-request through to the `new Request()` constructor should throw, but `workerd` has special handling to allow this if a `Request` instance is passed. Miniflare was previously decomposing the request before passing it back to the `new Request()` constructor, defeating this detection. This change ensures we always pass full `Request` instances to the `new Request()` constructor in the entry worker. Closes cloudflare/workerd#1122
Whilst prohibited by the `Request` API spec, `GET` requests are allowed to have bodies. If `Content-Length` or `Transfer-Encoding` are specified, `workerd` will give the request a (potentially empty) body. Passing a bodied-GET-request through to the `new Request()` constructor should throw, but `workerd` has special handling to allow this if a `Request` instance is passed. Miniflare was previously decomposing the request before passing it back to the `new Request()` constructor, defeating this detection. This change ensures we always pass full `Request` instances to the `new Request()` constructor in the entry worker. Closes cloudflare/workerd#1122
GET/HEAD requests that include a
Content-Length: 0
header assert when running CF workers locally in miniflare (ran through wrangler 3.0.0). E.g. take any worker, and make a GET request to it with this header:Yields:
Doing the same request against the CF workers playground is fine (omitted some headers for clarity here):
My guess is this pointer should not be set when
Content-Length: 0
is passed in (or there should be another check for headers here):workerd/src/workerd/api/http.c++
Line 854 in d28b0e1
Setting the Content-Length header on GET requests is f.e. used by Docker whenever it pulls manifests from Docker Hub (found this behavior when proxying these requests through a worker).
The text was updated successfully, but these errors were encountered: