tauri-apps / tauri-apps/plugins-workspace
Bug: HTTP fetch API call is blocked with no error
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
I'm using the [[Vanilla JS API](https://v2.tauri.app/reference/javascript/api/#vanilla-js-api)](https://v2.tauri.app/reference/javascript/api/#vanilla-js-api) from Tauri v2.
#### 💡 Problem
The `fetch` call from `@tauri-apps/plugin-http` returns a response object, but calling `response.json()` silently hangs — no error is thrown, and execution is blocked indefinitely.
#### 🧪 Minimal Reproduction
```js
const { fetch: tauriFetch } = window.__TAURI__.http;
class WeUploader {
constructor(imageHost) {
this.imageHost = imageHost;
this.tokenUrl = "https://example.com/token";
}
async fetchAccessToken() {
try {
const response = await tauriFetch(`${this.tokenUrl}?appid=xxx&secret=yyy`);
console.log(response); // response.bodyUsed is already true
const data = await response.json(); // hangs here with no error
console.log(data);
} catch (error) {
console.error("Failed to fetch access token", error);
}
}
}
```
🖼️ Screenshot (response is printed, but `response.json()` never resolves):
---
### 🔧 Environment Details
**`package.json`:**
```json
"devDependencies": {
"@tauri-apps/cli": "^2.3.1"
},
"dependencies": {
"@tauri-apps/api": "^2.3.0",
"@tauri-apps/plugin-http": "^2.3.0"
}
```
**`Cargo.toml`:**
```toml
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri-plugin-http = "2"
```
**`tauri.conf.json` permissions:**
```json
"permissions": [
{
"identifier": "http:default",
"allow": [
{ "url": "http://**" },
{ "url": "https://**" }
]
},
"http:allow-fetch",
"http:allow-fetch-cancel",
"http:allow-fetch-read-body",
"http:allow-fetch-send"
]
```
---
### ✅ Expected Behavior
Calling `await response.json()` should resolve to parsed JSON data, as in browser or other environments.
---
### 📌 Notes
* `response.bodyUsed` is already true when the response is logged, which may indicate the body is already consumed or incorrectly handled.
* There are no errors thrown, making debugging very difficult.
Let me know if you need a full reproduction repo. Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.