Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document HttpClient behavior in case of timeout (zero status code and empty body) #2214

Open
mysticfall opened this issue Nov 10, 2024 · 2 comments
Assignees

Comments

@mysticfall
Copy link

mysticfall commented Nov 10, 2024

Severity

Critical. A critical defect that causes some key functionality to fail.

Priority

High. Anything that impacts the typical user flow or blocks app usage.

Description

When I invoke an HTTP API using Skyrim Platform's HttpClient.post, it returns an invalid HttpResponse object in its callback with a status code of 0 and an empty body.

The request reaches the server with the correct information, and the server I tested with correctly responds with a 200 status code and a plain text message, which the client fails to retrieve.

It seems to work as expected on rare occasions, but I've failed to reproduce it reliably so far. HttpClient.get seems to work fine, in comparison.

OS

Linux

OS version

Manjaro/KDE/Wayland

Skyrim version

1.6.1170

SKSE version

2.2.6

client commit''s hash

(Skyrim Platform 2.9.0 Release)

server commit''s hash

N/A

Videocard model

NVidia RTX3080

Steps to reproduce

Here's a snippet of the code that shows the issue:

const http = new HttpClient("http://127.0.0.1:3001")

const payload = { // some JSON data }

http.post("/api/generate", {contentType: "application/json", body: JSON.stringify(payload)}, ).then(res => {
    // This prints "Status: 0, Error: , Body: " most of the times:
    printConsole(`Status: ${res.status}, Error: ${res.error}, Body: ${res.body}`)
})

Expected result

See the above example.

Actual result

See the above example.

@mysticfall
Copy link
Author

mysticfall commented Nov 10, 2024

After a bit more testing, I have a feeling that it might not have to do with post or get but with the timeout. If the server takes too long to respond, the client seems to return prematurely without an error.

I need more tests to confirm this behaviour. But in this case, a configurable timeout option with the promise failing upon exceeding the specified value could be nice.

@Pospelove Pospelove changed the title [Bug]: HttpClient.post returns an invalid HttpResponse Document HttpClient behavior in case of timeout (zero status code and empty body) Dec 11, 2024
@Pospelove
Copy link
Contributor

Great ticket! Hope we all be using fetch/axios soon with nodejs based SkyrimPlatform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants