nativescript-community / nativescript-community/https

GET fails with 'android.os.NetworkOnMainThreadException'

Open
#111 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vue
Stars
52
Forks
40
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the GET request from the issue on Android and compare the @nativescript-community/https path with core/http. Trace where the request is dispatched and identify why it reaches the main thread, then verify that the same request completes without NetworkOnMainThreadException and that existing Android behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.