Skip to content

[Notary] Improves Estimate of Response Size when Content-Length Absent#385

Merged
Step7750 merged 4 commits intomasterfrom
feature/improve-notary-response-size-estimate
Apr 9, 2026
Merged

[Notary] Improves Estimate of Response Size when Content-Length Absent#385
Step7750 merged 4 commits intomasterfrom
feature/improve-notary-response-size-estimate

Conversation

@Step7750
Copy link
Copy Markdown
Collaborator

@Step7750 Step7750 commented Apr 8, 2026

Transfer encoding responses don't have a Content-Length header. Currently, we severely overshoot the body size since it counts the decompressed bytes.

Instead, this PR switches to more reliable methods such as the resource timing API and re-compressing with leeway.

Ref CSF-1322


Note

Medium Risk
Changes how max_recv_data is estimated for chunked/gzipped responses; underestimation could cause notary/prover protocol failures, while overestimation mainly wastes headroom.

Overview
Improves response size estimation in calculateResponseSize when Content-Length is missing by switching from blob.size (decompressed bytes) to a prioritized set of on-wire approximations.

When no Content-Length is present, it now consumes the body and estimates size via Resource Timing encodedBodySize (with padding), then re-gzipping via CompressionStream (with leeway) when the response was gzip-encoded, and finally falls back to decompressed byte length; adds helper functions getEncodedBodySizeFromPerformance and estimateGzipSize and updates docs/debug logs accordingly.

Reviewed by Cursor Bugbot for commit dfceef0. Bugbot is set up for automated code reviews on this repo. Configure here.

Step7750 added 2 commits April 7, 2026 21:04
Transfer encoding responses don't have a `Content-Length` header. Currently, we severely overshoot the size since it counts the decompressed bytes.

Instead, this PR switches to more reliable methods such as the resource timing API and re-compressing with leeway.
@Step7750 Step7750 requested a review from GODrums April 8, 2026 03:15
@Step7750 Step7750 added the bug label Apr 8, 2026
@Step7750 Step7750 changed the title Improves Estimate of Response Size when Content-Length Absent [Notary] Improves Estimate of Response Size when Content-Length Absent Apr 8, 2026
Copy link
Copy Markdown
Collaborator

@GODrums GODrums left a comment

Choose a reason for hiding this comment

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

Complicated stuff, thanks for the comments!

Comment thread src/offscreen/handlers/notary_prove.ts
Comment thread src/offscreen/handlers/notary_prove.ts Outdated
@Step7750 Step7750 merged commit 7ae1fea into master Apr 9, 2026
3 checks passed
@Step7750 Step7750 deleted the feature/improve-notary-response-size-estimate branch April 9, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants