Skip to content

fix(runtime): track native Promise instances - #180

Merged
V3RON merged 3 commits into
mainfrom
agent/fix-native-promise-statics
Aug 4, 2026
Merged

fix(runtime): track native Promise instances#180
V3RON merged 3 commits into
mainfrom
agent/fix-native-promise-statics

Conversation

@V3RON

@V3RON V3RON commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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.construct still 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.resolve identity, and custom Promise subclass behavior. Harness still propagates context through then, catch, and finally, 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.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-harness Ready Ready Preview Aug 3, 2026 7:17pm

Request Review

@V3RON V3RON changed the title fix(runtime): preserve native Promise static methods fix(runtime): track native Promise instances Aug 3, 2026
@V3RON
V3RON marked this pull request as ready for review August 4, 2026 07:22
@V3RON
V3RON merged commit 458ef89 into main Aug 4, 2026
10 of 11 checks passed
@V3RON
V3RON deleted the agent/fix-native-promise-statics branch August 4, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant