Bug 215631 - Webkit incorrectly reuses closed tcp connections: Failed to load resource: The network connection was lost.
Summary: Webkit incorrectly reuses closed tcp connections: Failed to load resource: Th...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: Safari 13
Hardware: Mac macOS 10.15
: P2 Critical
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-18 16:47 PDT by kevmun
Modified: 2020-08-31 13:36 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kevmun 2020-08-18 16:47:27 PDT
In our webapp using webkit, we see an issue with certain AJAX requests, "Failed to load resource: The network connection was lost."

We have observed that using Fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) we hit a timing issue where the browser tries to reuse a connection that was recently closed. With optimal network conditions, it’s about a 2% chance of this occurring. With high latency packets, we can reproduce %15 of the time. 

Steps to repro:

Navigate at exactly 7 seconds (when our server terminates the connection, reproducing outside this environment will depend on the server timeouts).

We've observed our TCP connections to be in TIME_WAIT at the time of failure;

The docs here refer to webkit keeping connections open
https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/CommonPitfalls/CommonPitfalls.html
Comment 1 Radar WebKit Bug Importer 2020-08-19 00:50:06 PDT
<rdar://problem/67385261>
Comment 2 Alexey Proskuryakov 2020-08-19 15:30:11 PDT
> Navigate at exactly 7 seconds (when our server terminates the connection, reproducing outside this environment will depend on the server timeouts).

Can you share the server URL?
Comment 3 Alexey Proskuryakov 2020-08-31 13:36:47 PDT
As a workaround, can you use HTTP/2 instead instead of HTTP/1 or add `Keep-Alive: timeout=7` header?