question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

šŸ› BUG: `pages dev` HTTP 406 on `env.ASSETS.fetch()`

See original GitHub issue

What version of Wrangler are you using?

0.0.15

What operating system are you using?

Windows

Describe the Bug

Try this:

export const onRequestGet: PagesFunction<{}> = async ({ request, env, next, data, params }) => {
    const cloned = request.clone();
    const dest = `https://some-page.dev/`;
    return env.ASSETS.fetch(new Request(dest, { headers: cloned.headers }));
};

Run wrangler pages dev ./

Works as expected on Wrangler, fetches the index page for https://some-page.dev/. On Pages, env.ASSETS.fetch() returns a 406 error with no body. Iā€™ve confirmed that it is env.ASSETS.fetch() thatā€™s returning the error, and that the worker isnā€™t just dying.

Hereā€™s an example response:

        "response": {
          "status": 406,
          "statusText": "",
          "httpVersion": "h3",
          "headers": [
            {
              "name": "date",
              "value": "Tue, 01 Feb 2022 23:53:01 GMT"
            },
            {
              "name": "content-length",
              "value": "0"
            },
            {
              "name": "expect-ct",
              "value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
            },
            {
              "name": "report-to",
              "value": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=SEj8%2BhNNl%2F31mCPN76ltZtRFew7hoKTHlFyXPakdNoR2dpBUfCsl%2FaDStznbbAG6ZtmGQaCrIGJpV9fr3QFs%2BubBDV5Hi8fRKNLq3LB6sBCB3wUTt5Paa63t%2FN6Yz9djp6NE\"}],\"group\":\"cf-nel\",\"max_age\":604800}"
            },
            {
              "name": "nel",
              "value": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}"
            },
            {
              "name": "vary",
              "value": "Accept-Encoding"
            },
            {
              "name": "cf-cache-status",
              "value": "DYNAMIC"
            },
            {
              "name": "server",
              "value": "cloudflare"
            },
            {
              "name": "cf-ray",
              "value": "6d6f18c83c5e840e-YVR"
            },
            {
              "name": "alt-svc",
              "value": "h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
            }
          ],
          "cookies": [],
          "content": {
            "size": 0,
            "mimeType": "text/plain"
          },
          "redirectURL": "",
          "headersSize": -1,
          "bodySize": -1,
          "_transferSize": 514,
          "_error": "net::ERR_HTTP_RESPONSE_CODE_FAILURE"
        },

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Cherrycommented, Aug 4, 2022

This impacted another user in the Discord today: https://canary.discord.com/channels/595317990191398933/910978223968518144/1004857593656786974

Can we get some eyeballs on this issue please? Itā€™s a massive prod vs development issue when doing anything slightly advanced within Functions.

0reactions
Cherrycommented, Sep 18, 2022

This doesnā€™t just impact env.ASSETS.fetch. The following also triggers a 406, with an accompanying test.html file:

// functions/testing.js
export async function onRequestGet({request, next}){
    const url = new URL(request.url);
    url.pathname = '/test';
    return next(url.toString());
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Response "406 unacceptable" on env.ASSETS.fetch() for ...
Hi all, i am having a hard time debugging an issue while using Cloudflare pages functions. In a nutshell, at some point in...
Read more >
How to Fix a 406 Error and Find the Source of the Problem
The good news is that the HTTP error ā€œ406 Not Acceptableā€ message is not nearly as common as the 404 server error (which...
Read more >
406 Not Acceptable: What It Is and How to Fix It - Airbrake Blog
The 406 Not Acceptable is an HTTP response status code indicating that the client has requested a response using Accept- headers that theĀ ......
Read more >
Guidelines for Environmental Infection Control in Health-Care ...
pages ] (http://www.cdc.gov/hicpac/pdf/2018-Nov-HICPAC-Meeting-508.pdf). ... the negative pressure setting, and because of the potential for error associated.
Read more >
Changelog - Miniflare
Return Durable Object get() s in lexicographic order. ... Fix delivery of incoming WebSocket error events; Ensure only scheduled Durable Object alarms areĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found