fix(runtime): track native Promise instances - #180
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
This fixes a Harness v1.4 regression where enabling promise tracking replaces native Promise instances with subclass instances. On Hermes, that can make immediately settled native-module promises expose internal promise state instead of their resolved value.
How does it work?
The tracker now wraps the native Promise constructor in a Proxy. Its construction trap records pending work and wraps settlement callbacks while
Reflect.constructstill creates genuine native Promise instances. Static Promise factories are forwarded through stable wrappers so native results retain Harness test context without becoming subclass instances. When native-module JSI code invokes a captured static method without a receiver, the wrapper falls back to the captured native constructor.The Proxy preserves native prototypes,
instanceof, constructor identity,Promise.resolveidentity, and custom Promise subclass behavior. Harness still propagates context throughthen,catch, andfinally, and continues to omit its internal bookkeeping promises from tracking. Regression coverage verifies direct construction, subclassing, and every supported static method. The runtime suite, build, typecheck, lint, version-plan check, and affected-project pre-commit checks pass.Why is this useful?
Nitro and other native modules can return immediately fulfilled or rejected promises without Harness changing their values on Hermes. Promise leak diagnostics continue to work without changing the observable prototype of promises created by application or test code.