cloudflare / cloudflare/workerd

🐛 Bug Report — Fetch's body output causes a crash

Open
#1,275 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

[Edited] This may occur on only local environment. After deployed the code , it works fine.

## Issue Description:

When attempting to output the body from a fetch GET request in my environment, I encounter a crash. Interestingly, the same code works perfectly on POSTMan and in Python on Google Colab. Here's the specific TypeScript code causing the crash:

```typescript
const headers = {"Authorization": "Bearer MYKEY"}
fetch(urlWithParam,{headers}).then(async(r)=>{
console.log(JSON.stringify(Object.fromEntries(r.headers.entries())))
console.log(r.status)
console.log(r.statusText)
console.log(urlWithParam)

return r.json() //This crashes here and return nothing.
});

```

## Outputs
```txt ResponseHeader
{
"aa-request-id": "DUMMY_REQUEST_ID",
"connection": "keep-alive",
"content-encoding": "gzip",
"content-length": "10581",
"content-security-policy": "DUMMY_CONTENT_SECURITY_POLICY",
"content-type": "application/json",
"date": "Thu, 05 Oct 2023 02:25:53 GMT",
"server": "nginx",
"strict-transport-security": "max-age=31536000",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"x-xss-protection": "1; mode=block"
}
200
OK
https://example.com/DUMMY_URL?[with_some_params]

workerd/util/symbolizer.c++:98: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=`.
*** Fatal uncaught kj::Exception: kj/compat/gzip.c++:80: failed: header = gzip decompression failed; ctx.msg = incorrect header check
stack: /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@20808d7 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@2081067 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@1b024f7 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@1b022a3 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35dd8a3 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@20355c3 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35b7aa3 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35fc27b /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35b7d7b /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35b8f63 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@1b12113 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35b8d13 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35bcb87 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@35b39ef /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@17c9117 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@17ccfd7 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@17cce13 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@17ccdfb /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@361d873 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@361d5d3 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@361bbf3 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@361b9e7 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@17bf2cf /lib/aarch64-linux-gnu/libc.so.6@20e17 /usr/local/share/npm-global/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd@17bf033
```

## Environment Details:

Wrangler Version: 3.10.1
Node Version: 20.6.1
Machine: M2 Mac (running in a devcontainer )

```Dockerfile
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:20-bullseye
USER node

RUN sudo apt-get -y install libc++-dev

```

## This API works on different environments

In Google Colab, I used the following Python code which executed without any issues:

```python
headers = {"Authorization": "Bearer MYKEY"}
res = httpx.get(url, params=params, headers=headers)
res.raise_for_status()
ob = res.json()
```

Any guidance or possible fixes for this issue would be greatly appreciated. Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.