Skip to content

fix(android): add resolve queue to handle NsdManager single-resolve limitation#4

Merged
eliaslecomte merged 3 commits intomainfrom
feature/android-sequential-resolve-queue
Jan 23, 2026
Merged

fix(android): add resolve queue to handle NsdManager single-resolve limitation#4
eliaslecomte merged 3 commits intomainfrom
feature/android-sequential-resolve-queue

Conversation

@eliaslecomte
Copy link
Member

@eliaslecomte eliaslecomte commented Jan 22, 2026

Problem: Android's NsdManager.resolveService() can only handle one resolve at a time. The library was calling it for every discovered service simultaneously, causing most calls to fail silently with error code 3 (FAILURE_ALREADY_ACTIVE).

Solution: Queue discovered services and resolve them one at a time:

Before: Service1 → resolve() ❌
Service2 → resolve() ❌  (fails - already resolving)
Service3 → resolve() ❌  (fails - already resolving)

After:  Service1 → queue → resolve() ✓ → wait 50ms
Service2 → queue → resolve() ✓ → wait 50ms
Service3 → queue → resolve() ✓ → wait 50ms

This PR adds:

  • A queue to hold discovered services
  • Sequential processing (one resolve at a time)
  • Retry logic for transient failures
  • Small delays between resolves

@eliaslecomte
Copy link
Member Author

Struggled on low end devices like Oneplus 8. Searching for http:

Before
Finding only 1 device.

image

After
Finding all devices on the network.

image

@bitcrumb
Copy link
Member

This is a great find! 😅

@eliaslecomte eliaslecomte force-pushed the feature/android-sequential-resolve-queue branch from c753d6c to 9af304d Compare January 22, 2026 15:51
@eliaslecomte
Copy link
Member Author

eliaslecomte commented Jan 23, 2026

Root cause of iOS example build failure:

The CI was caching the ios/Pods directory based only on Podfile.lock. However, React Native's codegen generates C++ files (like RNServiceDiscoverySpecJSI-generated.cpp) based on the native module specs defined in the JS/TS code and the codegenConfig in package.json.

When native code or dependencies changed but Podfile.lock stayed the same, the cached Pods directory contained stale Xcode build rules that referenced generated files that would no longer be created, resulting in:

error: Build input file cannot be found: '.../RNServiceDiscoverySpecJSI-generated.cpp'

Fix

Extended the cocoapods cache key to include yarn.lock and package.json, so the cache invalidates when:

  • Pod versions change (Podfile.lock)
  • JS dependencies change, including react-native version (yarn.lock)
  • Codegen configuration changes (package.json)

Also updated the runner to macos-15 and Ruby to 3.3 for better compatibility with current tooling.

@eliaslecomte eliaslecomte merged commit 687bc7e into main Jan 23, 2026
5 checks passed
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.

2 participants