Skip to content

Update fetch-later spec according to WPT expectations #1902

Open
TimvdLippe wants to merge 2 commits intowhatwg:mainfrom
TimvdLippe:fetch-later-fixes
Open

Update fetch-later spec according to WPT expectations #1902
TimvdLippe wants to merge 2 commits intowhatwg:mainfrom
TimvdLippe:fetch-later-fixes

Conversation

@TimvdLippe
Copy link
Copy Markdown
Contributor

@TimvdLippe TimvdLippe commented Jan 4, 2026

There were two missing parts:

  1. The body can either be null or empty (it was missing the
    empty case)
  2. Quota computation shouldn't include aborted or already
    completed requests. WPT uses AbortController to ensure
    quota is freed up. This also makes sense, since they are
    no longer relevant. Therefore, only consider pending
    deferred fetches when computing quota.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

There were two missing parts:
1. The body can either be null or empty (it was missing the
empty case)
2. Quota computation shouldn't include aborted or already
completed requests. WPT uses `AbortController` to ensure
quota is freed up. This also makes sense, since they are
no longer relevant. Therefore, only consider pending
deferred fetches when computing quota.
@TimvdLippe
Copy link
Copy Markdown
Contributor Author

FYI @noamr PTAL

@noamr
Copy link
Copy Markdown
Contributor

noamr commented Feb 25, 2026

(2) is fine
Not sure about 1... Isn't posting an empty body a legit use case? The null use case was about not allowing streaming.

@TimvdLippe
Copy link
Copy Markdown
Contributor Author

Well, Chrome currently blocks such requests: https://wpt.fyi/results/fetch/fetch-later/quota/empty-payload.https.window.html?label=experimental&label=master&aligned If I didn't implement that case, Servo wouldn't match Chrome's behaviour.

@noamr
Copy link
Copy Markdown
Contributor

noamr commented Feb 25, 2026

Well, Chrome currently blocks such requests: https://wpt.fyi/results/fetch/fetch-later/quota/empty-payload.https.window.html?label=experimental&label=master&aligned If I didn't implement that case, Servo wouldn't match Chrome's behaviour.

@mingyc the spec only prevents null bodies (streaming) rather than empty... Do you remember why chromium also blocks empty requests?

@TimvdLippe we should check whether this is an implementation oversight or a spec oversight before defaulting to "spec what chromium does"... For the time being I think that the other part of the PR is ok.

@TimvdLippe
Copy link
Copy Markdown
Contributor Author

I wasn't aware of the streaming part. Since the test wasn't marked as tentative, I thought this part of the spec was meant to imply the empty case behaviour. I don't mind either behaviour (not familiar with streaming or anything), so happy to update it to whatever you folks decide.

@TimvdLippe
Copy link
Copy Markdown
Contributor Author

Friendly ping @mingyc on Chromiums perspective

@noamr
Copy link
Copy Markdown
Contributor

noamr commented Mar 24, 2026

Friendly ping @mingyc on Chromiums perspective

I suggest to make the other change and propose a WPT pr to align with the spec re empty request bodies

TimvdLippe added a commit to TimvdLippe/servo that referenced this pull request Mar 24, 2026
Per the spec discussion in [1] we should only check for a length
of `null` and not zero.

[1]: whatwg/fetch#1902

Signed-off-by: Tim van der Lippe <[email protected]>
servo-wpt-sync pushed a commit to servo/wpt that referenced this pull request Mar 24, 2026
Per the spec discussion in [1] we should only check for a length
of `null` and not zero.

[1]: whatwg/fetch#1902

Signed-off-by: Tim van der Lippe <[email protected]>
@TimvdLippe
Copy link
Copy Markdown
Contributor Author

Updated this PR and updated Servo + tests, see the WPT export in web-platform-tests/wpt#58726 Please review that PR.

TimvdLippe added a commit to TimvdLippe/servo that referenced this pull request Mar 24, 2026
Per the spec discussion in [1] we should only check for a length
of `null` and not zero.

[1]: whatwg/fetch#1902

Signed-off-by: Tim van der Lippe <[email protected]>
servo-wpt-sync pushed a commit to servo/wpt that referenced this pull request Mar 24, 2026
Per the spec discussion in [1] we should only check for a length
of `null` and not zero.

[1]: whatwg/fetch#1902

Signed-off-by: Tim van der Lippe <[email protected]>
@mingyc
Copy link
Copy Markdown

mingyc commented Mar 25, 2026

Sorry about missing this thread

@mingyc the spec only prevents null bodies (streaming) rather than empty... Do you remember why chromium also blocks empty requests?

I roughly remember there was some discussion about posting with empty body should be replaced by a GET request (can't find it now). Isn't null body the same as empty body in this context?

@annevk
Copy link
Copy Markdown
Member

annevk commented Mar 27, 2026

No they are distinct. One has a Content-Length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants