Skip to content

fix(runtime): expose the effective native member guard state to JS - #604

Merged
edusperoni merged 1 commit into
mainfrom
fix/native-member-guard-state
Nov 23, 2026
Merged

edusperoni merged 1 commit into
mainfrom
fix/native-member-guard-state

Conversation

@edusperoni

Copy link
Copy Markdown
Collaborator

Follow-up to #593, from its last CodeRabbit review. The native member guard is on only in debug builds under "rooted" or "canary" without allowShadowingNativeMembers, but the specs derived it from the mode and config alone. A Release run of the suite under rooted or canary therefore expected a guard the runtime leaves off.

Changes

  • New read-only ns:runtime key wrapperLifetimeGuardsNativeMembers: getConfig returns the runtime's effective guard state, and setConfig throws like the other read-only wrapper lifetime keys. It is documented in the config table and the "Native member guard" section, and typed in types/ns-runtime.d.ts.

  • NativeMemberGuardTests.js and WrapperLifetimeModesTests.js read the guard state from that key.

  • The "reports the guard state read-only" spec checks both directions:

    • if the guard is on, the mode is rooted or canary and shadowing isn't allowed;
    • in a debug build under rooted or canary with shadowing not allowed, the guard is on.

    Debug is detected the way HttpEsmLoaderTests does it, from canonicalizeHttpUrlKey, which the runtime exposes under the same IsDebug flag that gates the guard.

Testing

Build Mode Tests Failed
Debug default 2209 0
Debug rooted:all 2209 0
Debug canary:all 2209 0
Debug canary:extended 2209 0
Release, the two guard suites only canary:all 82 0 (the old specs fail 15 here)

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ac764752-bea2-4907-9ed9-6f341c3d4935
Commits

Reviewing files that changed from the base of the PR and between 8d0a4f1 and fe7945b.

Files selected for processing: 5

  • NativeScript/runtime/NsBuiltinModules.cpp
  • TestRunner/app/tests/NativeMemberGuardTests.js
  • TestRunner/app/tests/WrapperLifetimeModesTests.js
  • docs/ns-builtin-modules.md
  • types/ns-runtime.d.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The native member guard is on only in debug builds under the rooted and
canary wrapper lifetime modes, unless allowShadowingNativeMembers is set.
The specs derived it from the mode and that config alone, so a Release
run of the suite under rooted or canary expected a guard the runtime
leaves off.

Add the read-only ns:runtime config key wrapperLifetimeGuardsNativeMembers,
which reports GuardsNativeMembers(), and have NativeMemberGuardTests and
WrapperLifetimeModesTests read it. A spec checks the key both ways against
the mode, the shadowing config and the build (detected through the
debug-only ns:module canonicalizeHttpUrlKey export).
@edusperoni
edusperoni force-pushed the fix/native-member-guard-state branch from e305012 to fe7945b Compare November 23, 2026 03:33
@edusperoni
edusperoni marked this pull request as ready for review November 23, 2026 03:33
@edusperoni
edusperoni merged commit 77e9a79 into main Nov 23, 2026
14 checks passed
@edusperoni
edusperoni deleted the fix/native-member-guard-state branch November 23, 2026 04:41
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