Comments (6)
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.
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.
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.
As I mentioned in #84, is it invalid to have cleanupCallback
be an async function?
from proposal-weakrefs.
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.
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)
- README feedback from @jorendorff HOT 1
- HostCleanupFinalizationGroup needs to pick a VM decided max iteration count HOT 30
- Should the fg copy the empty cells before calling cleanup callback? HOT 4
- Add API summary to README.md HOT 2
- Use of 'Job' in KeepDuringJob is misleading HOT 4
- Problem with definition of liveness HOT 12
- Rename FinalizationGroup to FinalizationRegistry (or other name?) HOT 5
- Document FinalizationGroup independent lifetime
- Soft check for WeakRef with reclaimed referent? HOT 15
- makeWeakCached passes key for unregister token; keys are often primitives HOT 1
- Document expectations of WeakRef behavior in practice HOT 3
- Documentation should encourage people to use cleanupSome only when appropriate HOT 2
- cleanupSome on main thread questions HOT 18
- Guarantee finalizers being called soonish. HOT 3
- Is this proposal stable enough for other specs to make use of weak refs? HOT 8
- The WeakRef object can also cause memory leak, why not make the reference self null? HOT 6
- WeakRef.prototype.deref() is misnamed HOT 17
- Iterable WeakMap implementation in README is incorrect?
- Q: Why not to add `getKeys() : array` instead? HOT 5
- Will heldValue be GC, after cleanupCallback executed? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-weakrefs.