You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The size option have always been a node-fetch only option. It's not in the spec.
So I would like to deprecate/remove it also.
Describe the solution you'd like
In the attempts to align with the spec more correctly and having code that works the same way across undici, deno, browsers and node-fetch i would like for the size option to go away into a own separate user-land module.
Limiting the size can be tricky
it should really be using AbortController / AbortSignal to abort the request.
it needs to check content-length and take compression into consideration.
when no content-length is available it should stream & calculate & abort when exceeding.
weather or not it should handle redirects manually.
Describe alternatives you've considered
a own seperate module for handling size (similar to how we did it with timeout and provided a timer-signal)
Another possible solution is if we where to have fetchObserver and/or fetchEvent then one could also use AbortController to abort request in another way
we shipped size option way early before when there was not any possible way to abort a fetch... that may have been the biggest reason why it was added in the first place...
for now anybody would do:
constctrl=newAbortController()const{ signal }=ctrlconstres=awaitfetch(url,{ signal })constlen=res.headers.get('content-length')if(len&&Number(len)>1024){// to large, abort the responsectrl.abort()}awaitres.text()
The
size
option have always been a node-fetch only option. It's not in the spec.So I would like to deprecate/remove it also.
Describe the solution you'd like
In the attempts to align with the spec more correctly and having code that works the same way across undici, deno, browsers and node-fetch i would like for the size option to go away into a own separate user-land module.
Limiting the size can be tricky
Describe alternatives you've considered
Additional context
No other fetch impl have size limit
The text was updated successfully, but these errors were encountered: