Skip to content

net: Fix stale QUIC send times after a pause - #13479

Merged
jellefoks merged 4 commits into
youtube:mainfrom
ogarai:yts/fix_quic_stale_approximate_now
Oct 20, 2026
Merged

jellefoks merged 4 commits into
youtube:mainfrom
ogarai:yts/fix_quic_stale_approximate_now

Conversation

@ogarai

@ogarai ogarai commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Since #6188, QuicChromiumClock::ApproximateNow() returns a saved time
that only arriving packets refresh. After a pause in a download, the
next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'
Test: Playback Analysis yts tests over QUIC, 0 network errors in 21

Bug: 532158865

Since youtube#6188, QuicChromiumClock::ApproximateNow() returns a saved time
that only arriving packets refresh. After a pause in a download, the
next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'
Test: Playback Analysis yts tests over QUIC, 0 network errors in 21

Bug: 532158865
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ✅ PASS All checks passed
CI / android ✅ PASS Passed
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ✅ PASS Passed
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


net: Fix stale QUIC send times after a pause

Previously, QuicChromiumClock::ApproximateNow() returned a cached time
that was only refreshed when packets arrived. If a download was paused,
the next packet sent would use a timestamp from before the pause. This
caused QUIC to interpret the packet as being seconds overdue, resulting
in the connection being closed with a network error.

This change introduces a scoped mechanism so that the cached time is
only used during packet processing. In all other scenarios, the clock
is read directly to ensure timestamps remain current.

Bug: 532158865

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message
@ogarai
ogarai requested review from ckim1346 and jellefoks October 19, 2026 21:11

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the 'ZeroApproximateNow()' method with a RAII-based 'ScopedApproximateNow' class in 'QuicChromiumClock' for Cobalt builds, ensuring that 'ApproximateNow()' only returns cached time within active scopes. The changes also update 'QuicChromiumPacketReader' to use this new scope and introduce unit tests. Feedback on these changes highlights three key areas for improvement: making the global static variables 'thread_local' to prevent data races in multi-threaded environments, fixing a bug where nested scopes prematurely clear the cached time upon inner scope destruction, and adding comments to document the threading model of the new class as required by the repository style guide.

@ckim1346 ckim1346 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/ optional test coverage suggestion

@jellefoks jellefoks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! I am stoked to see this fix.

@jellefoks
jellefoks merged commit 16d2f9f into youtube:main Oct 20, 2026
854 of 888 checks passed
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 20, 2026
Refer to original PR: #13479

Since #6188, QuicChromiumClock::ApproximateNow() returns a saved time
that only arriving packets refresh. After a pause in a download, the
next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'
Test: Playback Analysis yts tests over QUIC, 0 network errors in 21

Bug: 532158865

(cherry picked from commit 16d2f9f)
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 20, 2026
Refer to original PR: #13479

Since #6188, QuicChromiumClock::ApproximateNow() returns a saved time
that only arriving packets refresh. After a pause in a download, the
next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'
Test: Playback Analysis yts tests over QUIC, 0 network errors in 21

Bug: 532158865

(cherry picked from commit 16d2f9f)
briantting pushed a commit that referenced this pull request Oct 20, 2026
Refer to original PR: #13479

Since #6188, QuicChromiumClock::ApproximateNow() returns a saved time
that only arriving packets refresh. After a pause in a download, the
next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'
Test: Playback Analysis yts tests over QUIC, 0 network errors in 21

Bug: 532158865

(cherry picked from commit 16d2f9f)
briantting pushed a commit that referenced this pull request Oct 26, 2026
Refer to original PR: #13479

Since #6188, QuicChromiumClock::ApproximateNow() returns a saved time
that only arriving packets refresh. After a pause in a download, the
next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'
Test: Playback Analysis yts tests over QUIC, 0 network errors in 21

Bug: 532158865

(cherry picked from commit 16d2f9f)
jellefoks added a commit that referenced this pull request Oct 30, 2026
…er a pause

Refer to original PR: #13479

Since #4489 (#6188 on main), QuicChromiumClock::ApproximateNow() returns a
saved time that only arriving packets refresh. After a pause in a download,
the next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'

(cherry picked from commit 16d2f9f)

Bug: 532158865
TAG=agy
CONV=b445991b-5706-491d-91f0-8f9c3d040204
jellefoks added a commit that referenced this pull request Nov 3, 2026
…13720)

[25.lts.1+] Cherry pick PR #13479: net: Fix stale QUIC send times after
a pause

Refer to original PR: #13479

Since #4489 (#6188 on main), QuicChromiumClock::ApproximateNow() returns
a
saved time that only arriving packets refresh. After a pause in a
download,
the next packet sent got the time from before the pause. QUIC saw it as
seconds overdue and closed the connection, and the fetch failed with
"network error".

The saved time is now only used while arriving packets are handled.
Everywhere else ApproximateNow() reads the clock.

Test: net_unittests --gtest_filter='QuicChromiumClockTest.*'

(cherry picked from commit 16d2f9f)

Bug: 532158865
TAG=agy
CONV=b445991b-5706-491d-91f0-8f9c3d040204
@ogarai
ogarai deleted the yts/fix_quic_stale_approximate_now branch November 4, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants