sveltejs / sveltejs/kit

Clarify and document how socket/network or application level timeouts should be configured

Open
#8,609 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

Server side fetch fails with

error TypeError: fetch failed
    at fetch (C:\Users\some-user\some-sveltekit-projekct\node_modules\undici\index.js:105:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (C:\Users\some-user\some-sveltekit-projekct\node_modules\undici\lib\core\connect.js:176:24)
      at C:\Users\some-user\some-sveltekit-projekct\node_modules\undici\lib\core\connect.js:123:46
      at Immediate._onImmediate (C:\Users\some-user\some-sveltekit-projekct\node_modules\undici\lib\core\connect.js:162:33)
      at process.processImmediate (node:internal/timers:471:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}

How should developers deal with services that are

  • slow during TCP/TLS handshake, "connect" phase
  • slow when reading from the client (= sveltekit sending request)
  • slow when writing to the client (= sveltekit waiting for response)

During connect, read and write timeouts can make the request fail. It is not clear how these can be configured

  • depending on the platform/adater used
  • depending on whether fetch is server side (= undici package) or client side ( = browser)

Related discord discussion

Describe the proposed solution

Clarify and document in sveltekit and adapters how different types of timeouts can be configured.
Is it correct that fetch (browser and/or undici?) supports http/1.1 only and is this a disadvantage? Is support for http2 or even http3 useful for reliability and performance?

Alternatives considered

No response

Importance

i cannot use SvelteKit without it

Additional Information

Nmap result when the service has a TCP connect timeout:

sudo nmap -Pn -sS -p 443 api.insee.fr
Starting Nmap 7.93 ( https://nmap.org ) at 2023-01-23 17:04 CET
Nmap scan report for api.insee.fr (143.196.255.207)
Host is up.
Other addresses for api.insee.fr (not scanned): 194.254.37.207

PORT    STATE SERVICE
443/tcp filtered  https

Nmap done: 1 IP address (1 host up) scanned in 3.15 seconds

Nmap result when the service does not have a TCP connect timeout:

sudo nmap -Pn -sS -p 443 api.insee.fr
Starting Nmap 7.93 ( https://nmap.org ) at 2023-01-23 17:04 CET
Nmap scan report for api.insee.fr (143.196.255.207)
Host is up (0.044s latency).
Other addresses for api.insee.fr (not scanned): 194.254.37.207

PORT    STATE SERVICE
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 1.29 seconds

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

The report points to server-side fetch through node_modules/undici/index.js and lib/core/connect.js, and asks about adapter- and browser-specific behavior; start by tracing those fetch entry points and existing adapter documentation. Done means documenting how connect, read, and write timeouts are configured across the mentioned environments and adapters.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.