Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeoutError thrown in NodeJS client #6306

Closed
muddy-alex opened this issue Dec 6, 2023 · 3 comments
Closed

TimeoutError thrown in NodeJS client #6306

muddy-alex opened this issue Dec 6, 2023 · 3 comments

Comments

@muddy-alex
Copy link

muddy-alex commented Dec 6, 2023

How frequently does the bug occur?

Always

Description

I'm using RealmJS in a NodeJS App that will sometimes start offline. When the app starts with an internet connection (and then loses/regains connectectivity intermittently) realm works great. However, when booting with no internet connection, the open() method is throwing an error.

TimeoutError: Timed out: Realm could not be downloaded in the allocated time: 30000 ms.

I've tried a combination of config changes (including adding timeout values) to prevent this timeout from being thrown, but all don't seem to affect this error being thrown.

    ...,
    cancelWaitsOnNonFatalError: false,
    existingRealmFileBehavior: {
      type: OpenRealmBehaviorType.OpenImmediately,
      timeOut: 1000,
      timeOutBehavior: OpenRealmTimeOutBehavior.OpenLocalRealm
    },
    newRealmFileBehavior: {
      type: OpenRealmBehaviorType.OpenImmediately,
      timeOut: 1000,
      timeOutBehavior: OpenRealmTimeOutBehavior.OpenLocalRealm
    },

And

subs.add(realm.objects(schema).filtered('tennant == $0', tennant), { behavior: WaitForSync.Never });

Am I misinterpreting the timeOutBehavior property? Or is the Realm client ignoring the given value and using OpenRealmTimeOutBehavior.ThrowException ?

Stacktrace & log output

Output from internal logger
=====================

[error] Failed to resolve 'ws.eu-west-1.aws.realm.mongodb.com:443': Host not found (authoritative)


Error thrown after 30s
======================
/Users/alex/Workspace/app/node_modules/realm/src/TimeoutPromise.ts:39
          this.handle.reject(new TimeoutError(message));

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

12.3.1

What services are you using?

Atlas Device Sync

Are you using encryption?

No

Platform OS and version(s)

OSX Arm64 & Linux Arm64

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

@muddy-alex
Copy link
Author

muddy-alex commented Dec 14, 2023

I've just witnessed the same issue happen when there is a service outage. We've recently switched from using the React Native client where we didn't have any of these issues, to NodeJS where they seem to have started appearing.

[error] Failed to connect to endpoint '52.16.113.157:443': Connection refused
[error] Failed to connect to 'ws.eu-west-1.aws.realm.mongodb.com:443': All endpoints failed
Sync Error!
SyncError: Failed to connect to sync: Connection refused
    at fromBindingSyncError (/app/node_modules/realm/dist/bundle.node.js:3736:16)
    at Object.errorHandler (/app/node_modules/realm/dist/bundle.node.js:7769:23) {
  isOk: false,
  code: 1034,
  category: 'UNKNOWN',
  reason: 'Failed to connect to sync: Connection refused',
  logUrl: '',
  userInfo: {},
  isFatal: false
}
/app/node_modules/realm/dist/bundle.node.js:4091
                    this.handle.reject(new TimeoutError(message));
                                       ^
TimeoutError: Timed out: Realm could not be downloaded in the allocated time: 30000 ms.
    at Timeout.<anonymous> (/app/node_modules/realm/dist/bundle.node.js:4091:40)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

@muddy-alex muddy-alex closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2023
@codenapps
Copy link

Did you guys found any solution

@muddy-alex
Copy link
Author

We had the config in the wrong place.

sync: {
      cancelWaitsOnNonFatalError: false,
      existingRealmFileBehavior: {
        type: OpenRealmBehaviorType.DownloadBeforeOpen,
        timeOut: 5000,
        timeOutBehavior: OpenRealmTimeOutBehavior.OpenLocalRealm
      },
      newRealmFileBehavior: {
        type: OpenRealmBehaviorType.DownloadBeforeOpen,
        timeOut: 5000,
        timeOutBehavior: OpenRealmTimeOutBehavior.OpenLocalRealm
      },
}

^ This originally wasn't nested within the sync property

@sync-by-unito sync-by-unito bot closed this as completed Feb 20, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants