Skip to content

fix(Worklets): networking in Bundle Mode on some setups#9897

Draft
tjzel wants to merge 1 commit into
mainfrom
@tjzel/worklets/fix-bundle-mode-networking
Draft

fix(Worklets): networking in Bundle Mode on some setups#9897
tjzel wants to merge 1 commit into
mainfrom
@tjzel/worklets/fix-bundle-mode-networking

Conversation

@tjzel

@tjzel tjzel commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

In some setups networking didn't work with Worklets Bundle Mode. I made a few changes to fix it:

  • WorkletsNetworking.mm — I changed the folly / JSI / TurboModule imports so they resolve across setups where the React-Core / React-jsi / FBReactNativeSpec module prefixes aren't reachable: I now import folly convert via react/utils/FollyConvert.h, jsi/JSIDynamic.h directly, and ReactCommon/RCTTurboModule.h instead of FBReactNativeSpec.
  • RNWorklets.podspec — I added the React-utils iOS platform header path to HEADER_SEARCH_PATHS so react/utils/FollyConvert.h resolves.
  • WorkletsModule.mm — I dropped the now-unused FBReactNativeSpec import from under WORKLETS_FETCH_PREVIEW_ENABLED.
  • network.native.ts — I added an eager require('react-native/Libraries/TurboModule/TurboModuleRegistry') at the top of initializeNetworking. In some setups globalThis.TurboModules wasn't populated yet by the time we read it, so the mock TurboModules were never registered. Requiring TurboModuleRegistry first ensures the global is set up before we use it.

Test plan

Enable Worklets Bundle Mode and use fetch from a worklet on a setup where networking previously failed:

  1. Turn on Bundle Mode with the WorkletsNetworking fetch preview enabled (WORKLETS_FETCH_PREVIEW_ENABLED).
  2. Build the iOS app — WorkletsNetworking.mm now compiles even where the folly/JSI headers aren't exposed under the React-Core / React-jsi prefixes.
  3. Call fetch(...) from a Worklet Runtime and confirm the request completes instead of crashing on missing TurboModules.

@tjzel tjzel marked this pull request as draft July 7, 2026 13:17
Fix the folly/JSI header imports in WorkletsNetworking.mm so they
resolve across setups: import folly convert via `react/utils/FollyConvert.h`
(adding the React-utils iOS platform header path in the podspec),
`jsi/JSIDynamic.h` directly, and `ReactCommon/RCTTurboModule.h` instead of
`FBReactNativeSpec`. Drop the now-unused `FBReactNativeSpec` import from
WorkletsModule.mm.

Also eagerly `require` TurboModuleRegistry in `initializeNetworking` so
`globalThis.TurboModules` is populated before it is used.
@tjzel tjzel force-pushed the @tjzel/worklets/fix-bundle-mode-networking branch from 411587c to 354cdcb Compare July 7, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant