7 / 7
Mar 28

Issue: App crashes when the internet is turned off.
Error :[Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb.com:443’: Host not found (authoritative)
*Environment:

  • @realm/react: ^0.6.2
  • realm: ^12.13.1
  • react-native: 0.75.4
  • Previous Behavior: Worked fine for the last 2 years without issues.
  • Current Behavior: Now crashes in offline mode instead of using local Realm DB.
  • Expected Behavior: Should function offline and sync when internet is restored.
  • Steps Taken:
    • Verified app works online.
    • Checked Realm offline-first configurations.
    • No recent major changes in Realm setup.
  • Need Help With:
    • Why is this issue occurring now?
    • How to prevent crashes in offline mode?
    • Any new configurations needed?

Looking forward to your support.

Hi @Rajan_Shah1 ,

It’s difficult to diagnose the issue without more context (for example, a full stack trace, not just a single line), if you can we suggest to open a Support case for us to obtain details that you may not want to make public.

As a first quick glance, can you publish the configuration you’re opening the Realm with? In detail, a good one should have

newRealmFileBehavior: { type: 'downloadBeforeOpen', timeOutBehavior: 'throwException' }, existingRealmFileBehavior: { type: 'openImmediately', timeOutBehavior: 'openLocalRealm' },

Alternatively, you can try to post an issue on the Realm JS SDK Github repository: please note, however, that Device Sync is a deprecated product.

8 days later

The issue is not resolved yet, Nothing is changed in my code and realm version is also not updated
import React, { memo } from ‘react’;
import AppSync from ‘./AppSync’;
import { UserProvider } from ‘@realm/react’;
import { BottomSheetModalProvider } from ‘@gorhom/bottom-sheet’;
import { RealmContext } from ‘…/…/…/realm-database/RealmConfig’;
import RealmAuthCheck from ‘./RealmAuthCheck’;
import { OpenRealmBehaviorType } from ‘realm’;

export default memo(() => {
const { RealmProvider } = RealmContext;

const handleSyncError = async (session: any, syncError: any) => { if (syncError.name === 'ClientReset') { console.log('syncError ClientReset', syncError); try { console.log('error type is ClientReset....'); } catch (err) { console.error('catch error', err); } } else { console.log('other sync error', syncError); // ...handle other error types } }; return ( <UserProvider fallback={RealmAuthCheck}> <RealmProvider sync={{ flexible: true, onError: handleSyncError, newRealmFileBehavior: { type: 'downloadBeforeOpen', timeOutBehavior: 'throwException' }, existingRealmFileBehavior: { type: 'openImmediately', timeOutBehavior: 'openLocalRealm' }, }} > <BottomSheetModalProvider> <AppSync /> </BottomSheetModalProvider> </RealmProvider> </UserProvider> );

});
ERROR [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb.com:443’: Host not found (authoritative)

This occurs only when device goes offline

Hi @Rajan_Shah1 ,

As you’re going offline, this is definitely expected, and is just an indication, the issue is how this error is handled.

As I wrote before, one line of error tells nothing, a full stack trace would be more useful to understand what happens after that error that’s leading to the crash: without that, it’s all a matter of guessing.

Have you tried to remove the onError callback altogether?

2025-03-28 16:42:19.933 28288-28288 Compatibil…geReporter com.hawak D Compat change id reported: 171228096; UID 10316; state: ENABLED
2025-03-28 16:42:19.938 28288-28288 ScrollerOp…ionManager com.hawak D registerConfigChangedListener
2025-03-28 16:42:19.940 28288-28288 com.hawak com.hawak W Accessing hidden field Landroid/widget/ScrollView;->mScroller:Landroid/widget/OverScroller; (unsupported, reflection, allowed)
2025-03-28 16:42:20.033 28288-32244 unknown:Vi…rtyUpdater com.hawak W Could not find generated setter for class com.swmansion.rnscreens.ScreensShadowNode
2025-03-28 16:42:20.214 28288-32243 Looper com.hawak W PerfMonitor longMsg : seq=98 plan=16:42:07.542 late=135ms wall=12535ms running=12425ms runnable=7ms io=14ms h=com.facebook.react.bridge.queue.MessageQueueThreadHandler c=com.facebook.jni.NativeRunnable procState=-1
2025-03-28 16:42:20.300 28288-28288 ScrollerOp…ionManager com.hawak D registerConfigChangedListener
2025-03-28 16:42:20.373 28288-28288 ReactNative com.hawak I [GESTURE HANDLER] Gesture handler is already enabled for a parent view
2025-03-28 16:42:20.409 28288-32243 ReactNativeJS com.hawak I ‘:rocket: ~ dealProducts:’, 235
2025-03-28 16:42:20.471 28288-32243 ReactNativeJS com.hawak I ‘:rocket: ~ dealProducts:’, 235
2025-03-28 16:42:20.600 28288-32243 ReactNativeJS com.hawak E [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb.com:443’: Host not found (authoritative)
2025-03-28 16:42:20.643 28288-32243 ReactNativeJS com.hawak E [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb.com:443’: Host not found (authoritative)
2025-03-28 16:42:20.666 28288-28288 Looper com.hawak W PerfMonitor doFrame : time=396ms vsyncFrame=0 latency=1ms procState=-1
2025-03-28 16:42:20.666 28288-28288 Choreographer com.hawak I Skipped 40 frames! The application may be doing too much work on its main thread.
2025-03-28 16:42:20.682 28288-28288 Looper com.hawak W PerfMonitor doFrame : time=16ms vsyncFrame=0 latency=338ms procState=-1 historyMsgCount=8
2025-03-28 16:42:20.694 28288-32243 ReactNativeJS com.hawak E [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb. com:443’: Host not found (authoritative)
2025-03-28 16:42:20.788 28288-32243 ReactNativeJS com.hawak E [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb. com:443’: Host not found (authoritative)
2025-03-28 16:42:21.350 28288-32243 libc com.hawak A Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x6fdb188d08 in tid 32243 (mqt_js), pid 28288 (com.hawak)

Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x6fdb188d08 in tid 32243 (mqt_js), pid 28288 (com.hawak)

:small_blue_diamond: Breaking it Down:
Fatal signal 11 (SIGSEGV) → A segmentation fault occurred.

code 2 (SEGV_ACCERR) → Access error, meaning the process tried to read/write memory it wasn’t allowed to.

fault addr 0x6fdb188d08 → The invalid memory address the app tried to access.

tid 32243 (mqt_js) → The crash happened in the JavaScript thread (mqt_js).

03-28 17:36:56.936 32095 6453 E ReactNativeJS: [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb. com:443’: Host not found (authoritative)
03-28 17:36:57.013 32095 6453 E ReactNativeJS: [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb. com:443’: Host not found (authoritative)
03-28 17:36:57.084 32095 6453 E ReactNativeJS: [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb. com:443’: Host not found (authoritative)
03-28 17:36:57.188 32095 6453 E ReactNativeJS: [Realm.Sync.Client.Network - error] Failed to resolve ‘ws.services.cloud.mongodb. com:443’: Host not found (authoritative)
03-28 17:36:57.363 6549 6549 W libc : Access denied finding property "persist.vendor.track.malloc.enable "
03-28 17:36:57.426 32095 6453 F libc : Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x6f11d2ed08 in tid 6453 (mqt_js), pid 32095 (com.hawak)
03-28 17:36:57.516 6556 6556 W libc : Access denied finding property “persist.vendor.track.malloc.enable”