nativescript-community / nativescript-community/https
GET fails with 'android.os.NetworkOnMainThreadException'
未關閉
還沒有人認領這個 Issue。
- 主要語言
- Vue
- 星號
- 52
- 分支
- 40
- PR 合併指標
- 30 天內沒有已合併 PR
描述
I'm testing on Android so I don't know about iOS.
Test code:
import * as HTTP from '@nativescript-community/https';
...
let url = "https://historylines.com/nexus/ttw.jsp?a=add&app=LA&uid=test_fde9f33899e13fcc&drill=Open%20Shooting%20-%20Single%20Target&shots=7";
console.log("logSession: "+url);
HTTP.request({
url: url,
method: "GET",
timeout: 30000
})
.then((response) => {
let content = response.content.toJSON();
console.log("logSession response: "+JSON.stringify(content, null, 4));
if(!content){
console.error("logSession response is missing content");
reject("logSession response is missing content");
}else{
resolve(content);
}
})
.catch((err) => {
console.error("logSession failed, "+err);
reject(err);
});
When I run this code or similar with core/http, it succeeds. When I put the URL in a web browser, it succeeds. When I run with https, it fails with:
logSession failed, Error: android.os.NetworkOnMainThreadException
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,在 Android 上重現 issue 中的 GET 請求,並比較 @nativescript-community/https 路徑與 core/http。追蹤請求在哪裡被分派,並找出它為何會到達 main thread,接著確認相同的請求能在不出現 NetworkOnMainThreadException 的情況下完成,且現有的 Android 行為維持不變。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- android, javascript
- 領域
- mobile, networking
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100