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

Code compiles, however doesn't work as expected, I was asked to issue this. #8026

Open
berke-yilmaz opened this issue Sep 18, 2024 · 2 comments

Comments

@berke-yilmaz
Copy link

berke-yilmaz commented Sep 18, 2024

SDK and version

SDK : ? (Cocoa, Java, etc)
Swift
Version: ?
Last Version

Observations

  • How frequent do the crash occur? every time
  • Does it happen in production or during dev/test? production
  • Can the crash be reproduced by you? yes
  • Can you provide instructions for how we can reproduce it? by compiling

Crash log / stacktrace

/Users/mac/Library/Developer/Xcode/DerivedData/chessbrk-fbjogatoybvdkibovkkgafrsticz/SourcePackages/checkouts/realm-core/src/realm/sync/noinst/client_impl_base.hpp:1340: [realm-core-14.12.1] Assertion failed: m_error_message_received || !m_unbind_message_sent
0 RealmSwift 0x000000010c8fbed4 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 56
1 RealmSwift 0x000000010c8fbe98 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 352
2 RealmSwift 0x000000010c8fbd38 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 0
3 RealmSwift 0x000000010c61efb8 _ZN5realm4sync10ClientImpl7Session40request_download_completion_notificationEv + 316
4 RealmSwift 0x000000010c61ee28 _ZZN5realm4sync14SessionWrapper14async_wait_forEbbNS_4util14UniqueFunctionIFvNS_6StatusEEEEEN4$10clES4 + 684
5 RealmSwift 0x000000010c61eaa8 _ZN5realm4util14UniqueFunctionIFvNS_6StatusEEE12SpecificImplIZNS_4sync14SessionWrapper14async_wait_forEbbS4_E4$10E4callEOS2 + 96
6 RealmSwift 0x000000010c3c487c ZNK5realm4util14UniqueFunctionIFvNS_6StatusEEEclES2 + 156
7 RealmSwift 0x000000010c724c68 _ZZN5realm4sync10ClientImpl4postEONS_4util14UniqueFunctionIFvNS_6StatusEEEEENK3$1clES4 + 96
8 RealmSwift 0x000000010c724b48 _ZN5realm4util14UniqueFunctionIFvNS_6StatusEEE12SpecificImplIZNS_4sync10ClientImpl4postEOS4_E3$1E4callEOS2 + 96
9 RealmSwift 0x000000010c3c487c ZNK5realm4util14UniqueFunctionIFvNS_6StatusEEEclES2 + 156
10 RealmSwift 0x000000010c65dc78 _ZN5realm4sync7network7Service8PostOperINS_4util14UniqueFunctionIFvNS_6StatusEEEEE19recycle_and_executeEv + 88
11 RealmSwift 0x000000010c69154c _ZN5realm4sync7network7Service4Impl7executeERNSt3__110unique_ptrINS2_9AsyncOperENS2_18LendersOperDeleterEEE + 52
12 RealmSwift 0x000000010c6910e0 _ZN5realm4sync7network7Service4Impl8run_implEb + 484
13 RealmSwift 0x000000010c68bc38 _ZN5realm4sync7network7Service4Impl17run_until_stoppedEv + 48
14 RealmSwift 0x000000010c68bbfc _ZN5realm4sync7network7Service17run_until_stoppedEv + 44
15 RealmSwift 0x000000010c65d158 _ZN5realm4sync9websocket21DefaultSocketProvider10event_loopEv + 464
16 RealmSwift 0x000000010c66285c ZNSt3__18__invokeB8ue170006IMN5realm4sync9websocket21DefaultSocketProviderEFvvEPS4_JEvEEDTcldsdeclsr3stdE7declvalIT0_EEclsr3stdE7declvalIT_EEspclsr3stdE7declvalIT1_EEEEOS9_OS8_DpOSA + 132
17 RealmSwift 0x000000010c6627cc _ZNSt3__116__thread_executeB8ue170006INS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEMN5realm4sync9websocket21DefaultSocketProviderEFvvEJPS9_EJLm2EEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 64
18 RealmSwift 0x000000010c6623b8 ZNSt3__114__thread_proxyB8ue170006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEMN5realm4sync9websocket21DefaultSocketProviderEFvvEPSA_EEEEEPvSF + 100
19 libsystem_pthread.dylib 0x00000001045d3414 _pthread_start + 104
20 libsystem_pthread.dylib 0x00000001045ce5e0 thread_start + 8
!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose

Steps & Code to Reproduce

func configureFlexibleSync() async throws -> Realm {
print("Starting configureFlexibleSync function...")

// Ensure the current user exists
guard let user = app.currentUser else {
    print("No logged-in user found.")
    throw NSError(domain: "Login Error", code: 401, userInfo: [NSLocalizedDescriptionKey: "No logged-in user found."])
}

print("Current user: \(user)")

let config = user.flexibleSyncConfiguration()
print("Flexible sync configuration created.")

// Open Realm asynchronously
let realm = try await Realm(configuration: config)
print("Realm opened successfully.")

// Safely unwrap the email property outside of the subscription update block
guard let userEmail = user.profile.email else {
    print("User profile email not found.")
    throw NSError(domain: "Profile Error", code: 402, userInfo: [NSLocalizedDescriptionKey: "User profile email not found."])
}
print("User email: \(userEmail)")

// Update subscriptions without removal to avoid potential issues
try await realm.subscriptions.update {
    print("Updating subscriptions...")

    // Check if a subscription for UserProfile already exists
    if let existingSubscription = realm.subscriptions.first(named: "UserProfile") {
        print("Existing subscription for UserProfile found.")
    } else {
        print("No existing subscription found for UserProfile. Adding new subscription for user: \(userEmail)")
        // Add a new subscription for the UserProfile filtered by email
        realm.subscriptions.append(QuerySubscription<UserProfile>(name: "UserProfile") {
            $0.email == userEmail
        })
    }
}

print("Subscriptions updated successfully.")

// Return the Realm instance after the subscriptions are updated
return realm

}

@berke-yilmaz berke-yilmaz changed the title Code compiles, however doesn Code compiles, however doesn't work as expected, I was asked to issue this. Sep 18, 2024
Copy link

sync-by-unito bot commented Sep 18, 2024

➤ PM Bot commented:

Jira ticket: RCORE-2258

@jedelbo
Copy link
Contributor

jedelbo commented Sep 18, 2024

@tgoyne any immediate comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants