Giter Site home page Giter Site logo

Comments (6)

gsathya avatar gsathya commented on July 30, 2024 1

I think it's fine to throw an exception in that case. A good error message should make it clear what the problem is and how to fix it.

from proposal-weakrefs.

erights avatar erights commented on July 30, 2024

I think I prefer "throw" though I see arguments for "done". Either seem like something we can live with. What other options might there be?

from proposal-weakrefs.

littledan avatar littledan commented on July 30, 2024

The current specification text doesn't have a clear answer here. There's logic to return "done" when [[FinalizationGroup]] becomes undefined, but I don't see anything that sets it that way. I don't have an opinion between throw and return "done". It seems like it'd be pretty easy to set the FinalizationGroup to undefined when the finalization turn is done.

from proposal-weakrefs.

mhofman avatar mhofman commented on July 30, 2024

As I mentioned in #84, is it invalid to have cleanupCallback be an async function?

from proposal-weakrefs.

littledan avatar littledan commented on July 30, 2024

In general, code shouldn't be distinguishing between sync and async functions, just treating all functions which return a Promise the same. In this case, no one cares about the return value of this function. But if it's async and awaits, it may cause the exception to be thrown.

from proposal-weakrefs.

mhofman avatar mhofman commented on July 30, 2024

An exception thrown is exactly what I'm concerned about, especially because the exception would only be thrown if the iterator yields more than one element.

As a developer, I might be surprised to have code like this fail:

finalizationGroup.cleanupSome(async (items) => {
  for (const holding of items) {
    await freeStuff(holding);
  }
});

from proposal-weakrefs.

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.