fix(vite): await the client strategy before /ns/rt $navigateTo reports the navigator missing - #11424
Merged
NathanWalker merged 1 commit intoSep 10, 2026
Conversation
…s the navigator missing Fixes NativeScript#11422
|
View your CI Pipeline Execution ↗ for commit a95bc50
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
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.
PR Checklist
What is the current behavior?
Under HMR the served
/ns/rtbridge replacesnativescript-vue's$navigateTowith one that routes throughglobalThis.__nsNavigateUsingApp. That global is installed by the Vue client strategy'sinstall(), which runs in the.then()of the dynamicimport()inhmr/client/strategy-loader.ts— one HTTP fetch on device that nothing awaits before app code runs. Measured on an iOS simulator the navigator shows up ~400ms after root mount, so a root/loader component that navigates shortly after mount (auth check →$navigateTo(Home)) throws:The same code works with
--no-hmr. Details and measurements in #11422.What is the new behavior?
/__ns_dev__/clientbootstrap wrapper (createNsDevClientBootstrapCode) creates a deferredglobalThis.__NS_CLIENT_STRATEGY_READY__when it evaluates — that is before the app entry is imported, whereas the full client (and with itstrategy-loader.ts) is only imported once__NS_HMR_BOOT_COMPLETE__flips, i.e. after the entry has evaluated.strategy-loader.tssettles that deferred whenCLIENT_STRATEGY_READYsettles (or publishes its own promise on hosts without the wrapper). If the full client fails to start, the wrapper settles it too, so callers reject instead of hanging. The generated bridge can't import the loader; it only seesglobalThis.$navigateTostill calls the navigator synchronously when it is already installed. When it isn't, it now returns__NS_CLIENT_STRATEGY_READY__.then(...), navigating once the strategy has installed the navigator, and only throwsapp navigator missingonce the strategy has settled without installing one. With no readiness promise on the global (non-HMR hosts, tests) it throws synchronously exactly as before.__navigateNow/__navigatorMissingare added toRESERVED_BRIDGE_LOCALSso a vendor export can't collide with the helpers.vite-plugin-path.spec.tspins the deferred to the wrapper, ahead of the socket connect, and the settle-on-failure path. Tests inns-rt-bridge.spec.tslift the generated$navigateToout of the module text and evaluate it against a stub global: sync path, late-install path, settled-without-navigator path, no-promise path, and navigator errors surfacing unchanged.Note on the return value: in the not-yet-ready case
$navigateToreturns a Promise instead ofundefined. The bridge's navigator already returnsundefined(not thePagethe stock helper returns), so no caller inside the package depends on the value; app code thatawaits or ignores it is unaffected.Verified on device (iOS simulator, blank
ns createVue app +nativescript-vite init): a root component navigating 150ms after mount fails with the published 8.0.5 and navigates with this build; live edits still hot-reload.Fixes #11422.