POST requests with body content stuck in "pending"...
# workers-help
d
Copy code
async fetch(request:Request, env:Env, context:ExecutionContext):Promise<Response> 
    {
        let response = new Response('{}');
        response.headers.set('Access-Control-Allow-Headers', 'Content-Type, X-Json');    
        response.headers.set('Access-Control-Allow-Origin', '*');
        response.headers.set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
        response.headers.set('Access-Control-Max-Age', '86400');
        return response;
    }
The above works fine with requests without a body. When I add a body to the request the request is stuck in 'pending' status. Just adding this
Copy code
options.body = body;
causes the issue.
Copy code
Accept:
*/*
Accept-Encoding:
gzip, deflate, br
Accept-Language:
en-US,en;q=0.9
Cache-Control:
no-cache
Connection:
keep-alive
Content-Length:
1780366
Content-Type:
application/octet-stream
Host:
127.0.0.1:8081
Origin:
http://localhost
Pragma:
no-cache
Referer:
http://localhost/
Sec-Ch-Ua:
"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"macOS"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
cross-site
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
the worker gets the request, but the returned response somehow does not complete the request
weird, so i notice if i try to upload a file under 250kb or so, it works just fine. if i go a little above that, say 350kb, the upload request will work, but the subsequent request (with no body data) will be stuck in a pending state. if I try to upload something around 2mb in size, the upload request itself will be stuck in a pending state. this is crazy. how has this not been caught by now? is nobody doing local development?
to anyone encountering this issue in the future: this is due to a bug in miniflare, which occurs when your code does not consume the response body. i was piping the body through a transform steam, which appears to have an issue, and thus did not consume the response body.