Cloudflare worker not processing compressed data correctly

What I want to do is to utilize the api of uniprot https:::www,uniprot,org/help/id_mapping(I am told I cannot include links in the post so please replace :: with // and , with .).
What the worker did is to submit a job, wait for the job to complete and retrieve the result of the job. I’ve tested the worker code in Quick Edit section of worker, and it worked. But when I use wrangler publish to deploy the worker, the retrieved job result looks scrambled, likely due to misinterpretation of encoding, while job submitting and job status querying still works.

I’ve tried use curl to access the job result url, the result looks ok.
What is going wrong here?

below is the log of scrambled response text

here is the code, to test this worker, post below json to it.

{
  "geneList": ["ACTB", "GAPDH"],
  "taxId": 9606
}
async function submitJob(geneList, taxId) {
	const jobUrl = "https://rest.uniprot.org/idmapping/run";
	let formData = new FormData();
	formData.append("from", "Gene_Name");
	formData.append("to", "UniProtKB-Swiss-Prot");
	formData.append("ids", geneList.join(","));
	formData.append("taxId", taxId);
	for (const [key, value] of formData.entries()) {
		console.log(`${key}=${value}`);
	}
	const init = {
		method: "POST",
		body: formData
	};
	const resp = await fetch(jobUrl, init);
	const result = await resp.json();
	console.log(result);
	const jobId = result.jobId;
	return jobId;
}

async function getJobResult(jobId) {
	const jobStatusUrl = `https://rest.uniprot.org/idmapping/status/${jobId}`;
	while (true) {
		const statusResp = await fetch(jobStatusUrl, { redirect: "manual" });
		const status = await statusResp.json();
		console.log(status);
		// if result.results is not null
		if (status.jobStatus == "FINISHED") {
			const jobResultUrl = `https://rest.uniprot.org/idmapping/uniprotkb/results/stream/${jobId}?format=json`;
			const resultResp = await fetch(jobResultUrl);
			console.log(`response headers: ${JSON.stringify(Object.fromEntries(resultResp.headers))}`);
			const resultText = await resultResp.text();
			console.log(`response text: ${resultText}`);
			const resultJson = JSON.parse(resultText);
			return resultJson.results
		}
		// sleep 1s
		await new Promise(resolve => setTimeout(resolve, 1000));
	}
}



function extractCommentsFromResult(result) {
	const itemObj = result.map(item => {
		let itemObj = {};
		itemObj.gene = item.from;
		itemObj.uniprotId = item.to.uniProtkbId;
		itemObj.uniprotAccession = item.to.primaryAccession;
		itemObj.commentText = item.to.comments.map(comment => {
			let commentText = "";
			if (comment.commentType == "FUNCTION") {
				commentText += comment.texts.map(text => {
					return text.value;
				}).join("\n")
				commentText += "\n";
			}
			return commentText;
		}).filter(singleCommentText => singleCommentText.length > 0).join("\n") + "\n\n";
		return itemObj;
	});
	return itemObj;
}

export default {
	async fetch(request) {
		const pathname = new URL(request.url).pathname;
		if (!pathname.startsWith('/api/v1')) {
			return new Response("Current only support /api/v1/*", { status: 404 });
		}
		const requestBody = await request.json();
		const jobId = await submitJob(requestBody.geneList, requestBody.taxId);
		const idMappingResult = await getJobResult(jobId);
		return new Response(JSON.stringify(extractCommentsFromResult(idMappingResult)), { status: 200 });
	},
};