Giter VIP home page Giter VIP logo

Comments (9)

sof avatar sof commented on May 27, 2024 1

Thanks, Blink's behavior now follows suit.

from xhr.

bzbarsky avatar bzbarsky commented on May 27, 2024

So return null and then keep returning null thereafter? As in, once you fail to get the data, you're never going to get it, even if you free up some memory?

It does have the benefit of consistency....

from xhr.

bzbarsky avatar bzbarsky commented on May 27, 2024

Oh, and I guess the spec actually defines the lazy allocation behavior inside the response getter that Gecko has, so at least that part will be consistent...

from xhr.

annevk avatar annevk commented on May 27, 2024

Yeah, once you fail to get the data you won't get it unless you fetch it again and get lucky.

from xhr.

annevk avatar annevk commented on May 27, 2024

That's what happens for fetch() too since it effectively tries to consume the stream and then create the ArrayBuffer with the result. If you cannot create the ArrayBuffer, you cannot really unconsume the stream either (not that that even makes sense).

from xhr.

tyoshino avatar tyoshino commented on May 27, 2024

Currently, Chrome crashes when it fails to allocate an ArrayBuffer as it wasn't specified to throw an exception in the spec at the time we decided how to handle the case.

Unless there'll be any confusion, returning null should be fine. What's the reliable way to distinguish alloc failure and other errors (network error)? Saw "load" being dispatched, but seeing null on response?

+1 to Boris regarding consistency.

from xhr.

annevk avatar annevk commented on May 27, 2024

@tyoshino, yeah, I guess that would be the way they get distinguished indeed.

from xhr.

sof avatar sof commented on May 27, 2024

If allocation of the underlying buffer fails, https://xhr.spec.whatwg.org/#arraybuffer-response tells us to return a null response object, along with resetting 'received bytes' to empty. Doesn't that imply that the next property access of response will return an empty array buffer, and not null - is that intentional?

(This came up via https://codereview.chromium.org/2730943002/ )

from xhr.

annevk avatar annevk commented on May 27, 2024

Yeah that is broken. Proposal: response object can be an object, failure, or null and we update all the places that use it accordingly. I don't think we can get away with not using some extra state somehow.

from xhr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.