Skip to content

http timeout seems not to work #6523

@felixkrautschuk

Description

@felixkrautschuk

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI:
  • Cross-platform modules: 4.2.1
  • Android Runtime: 4.2.0
  • iOS Runtime: -
  • Plugin(s): -

Describe the bug
I try to set a timeout for our http requests in our NativeScript app, but the timeout property has no effect for me while testing.

To Reproduce
Here is what I am doing:

httpModule.request({
        url: "http://www.mocky.io/v2/5be3174d2f00007b00ca2260?mocky-delay=10000ms",
        timeout: 5000,
        method: "GET",
        headers: { }
}).then((response) => {
        const result = response.content.toJSON();

        alert("Received response: " + response.content);
    }, (e) => {
});

The provided url leads to a sample webservice from https://www.mocky.io/ and the delay is set to 10 seconds.

Open the provided sample app and tap the button.
It will start the http request and after about 10 seconds, you get an alert with the json response.

Expected behavior
Setting the timeout to 5000 ms, I would expect, that the http request was canceled and that I would get to the failure part of the Promise.

Sample project
NSHttpTimeout.zip

Additional context
Maybe I am misunderstanding the sense of the timeout property.
The reason for me setting this property:
I want to prevent, that the user waits for a long time to get the response of an http request. Instead there should be a 'maximum' time (i.e. 10 seconds) for the user to wait and when this time has passed, the loading indicator should be hidden and it should ignore the response of this request, if it is received later.
Is this not the function of the timeout property?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions