hermes: Missing property: `Promise.prototype[Symbol.toStringTag]`
Bug Description
https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise.prototype-@@tostringtag requires Promise.prototype to have a Symbol.toStringTag property with value “Promise”, but it is absent in Hermes.
- I have
runconfirmed this bug does not occur with JSCgradle cleanand
Hermes version: 0.11.0
Steps To Reproduce
code example:
Promise.prototype[Symbol.toStringTag]
The Expected Behavior
“Promise”
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
https://npmjs.com/es6-shim is fully compliant, if you wanted to consider an alternative.
@leotm You can add any
Promiseyou’d like by putting it on the global object as usual. The caveat: the reason we subsumed the existing Promise polyfill into Hermes was to supportasync/await, which is required to use the VM’s built-in of Promise, which can’t be overridden by users.So if you were to overwrite
globalThis.Promise, you’d end up with different semantics on that than the Promises generated byasync function.Absolutely! I’ll see if i can get that done in the next week or so.
9/5 edit: haven’t done it yet, but it’s near the top of my list 😃
9/11 update: i’m waiting on an npm package name reachout, but i’ll have it ready asap once that’s done
9/23 update: i’m still working on adapting the es6-shim implementation to a standalone form, when it’s done I’ll publish it even if i i have a subpar package name.
(I’m still working on this fwiw, but it’s turning out to be quite complex to polyfill Promise in a non-automatically-installed kind of way)
@ljharb we discussed it at length and decided it is high time we became spec-compliant as much as possible. Does your offer to split the Promise shim still stand? We would love to use it.
@grifotv if you believe there is a problem in Hermes, please create a minimal repro without React Native, submit a new issue (since this issue specifically is about
Promise.prototype[Symbol.toStringTag], and we will take a look.We (the Hermes team) can’t provide meaningful help about React Native, we are only focusing on the JS engine.
@ljharb offer much appreciated, thank you! I will reach out in the es6-shim repo if we need help. Changing the Promise implementation is a very risky process, I don’t think we have any benchmarks for it in place yet. Previously we simply took the polyfill already in use, so there was no need to worry about perf or functionality regressions.
You’re right that it’s not separated; I would be happy to split it out if that helps the hermes team.
Bluebird remains the fastest by violating the spec in a number of small ways; I’m not sure about the performance at this point tbh, but I’m also open to performance improvements as long as they don’t violate the spec.