Open kriskowal opened 3 months ago
Another thing promise kit does is address some memory leak issue that some engines have. I believe we'll need to no matter what unconditionally install a repaired version of withResolvers
, likely as a trusted ses shim.
What is the Problem Being Solved?
JavaScript now has a Promise.withResolvers function that overlaps with
@endo/promise-kit
. We can expect folks to want to pattern their code after Promise.withResolvers and continue to benefit from the further accommodations for eventual-send that we make in@endo/promise-kit
.Description of the Design
There are various ways we can refactor to make the Promise.withResolvers pattern canon going forward.
First, may still need a “ponyfill” (a module that exports a future language behavior that will delegate to that behavior when present, but provides its own implementation for all other cases). For that purpose,
@endo/promise-kit
already serves a similar purposes and we could do various things to make it better resemble aPromise.withResolvers
ponyfill.But, falling through to the real Promise.withResolvers may not be sufficient because of the further accommodations for eventual send in HandledPromise. We could shim (replace the native implementation on the global) to expose those fixes to all Promise usage in the realm.
And, I expect that there are combinations and permutations of these two themes.
Security Considerations
None.
Scaling Considerations
Must preserve existing fixes for memory leaks.
Test Plan
TBD
Compatibility Considerations
Should be possible to solve this problem additively.
Upgrade Considerations
New code should continue to work on old platforms. That constrains the design when a shim is or is not applied by the host environment.