Skip to content

http.get only return after timeout #20283

@carlosqsilva

Description

@carlosqsilva

Describe the bug

http.get only returns after read_timeout, this is happening only on localhost (tested with 127.0.0.1 as well)

Reproduction Steps

start any api locally, ex:

google-chrome --headless --remote-debugging-port=4000
module main

import net.http

fn main() {
   response := http.get('http://127.0.0.1:4000/json/version')!
   eprintln(response.body)
}

response.body will be printed after 30 seconds (default read_timeout value)

changing read_timeout:

module main

import net.http
import time

fn main() {
  req := http.Request{
    url: "http://127.0.0.1:4000/json/version"
    method: .get
    read_timeout: 5 * time.second 
  }
  response := req.do()!
  eprintln(response.body)
}

response.body will be printed after 5 seconds

curl http://120.0.0.1:4000/json/version

returns immediately, with no additional delay

Expected Behavior

http.get returns immediately when request has finished

Current Behavior

http.get returns when reach timeout

Possible Solution

No response

Additional Information/Context

can't reproduce to external apis (ex: https://api.github.com/users/...) only localhost

V version

0.4.3 b944927

Environment details (OS name and version, etc.)

V full version: V 0.4.3 8f76a06.b944927
OS: macos, macOS, 14.3, 23D5033f
Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /Users/carlossilva/Code/v_issues
vexe: /Users/carlossilva/Code/v/v
vexe mtime: 2023-12-27 21:50:04

vroot: OK, value: /Users/carlossilva/Code/v
VMODULES: OK, value: /Users/carlossilva/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.43.0
Git vroot status: weekly.2023.37-756-gb944927f
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
thirdparty/tcc status: thirdparty-macos-arm64 a668e5a0

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions