Skip to content

Invalid assertion or invalid sync engine access when sync engine isn't started #401

@KaiOelfke

Description

@KaiOelfke

Description

SQLiteData reports assertions when using startImmediately: false for the SyncEngine.

Private sync engine has not been set.
Shared sync engine has not been set.

Steps:

  1. Clone SQLite data and setup SyncUps in Examples project with bundle and cloud kit container ID's
  2. Change defaultSyncEngine setup in bootstrapDatabase to:

defaultSyncEngine = try SyncEngine(
   for: database,
   tables: SyncUp.self,
   Attendee.self,
   Meeting.self,
   startImmediately: false
  )

  1. Run app, seed, switch to home screen or change the application state some how

The same doesn't happen with startImmediately: true so this seems like a false assertion or something is running and trying to access sync engines where it shouldn't, because the sync engine wasn't started. If you e.g. have a breakpoint as issue reporter this is disruptive.

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • I have determined whether this bug is also reproducible in a vanilla GRDB project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

When the sync engine is not started via startsImmediately or it's stopped via .stop() there should be no assertions with a valid setup.

Actual behavior

When the sync engine is not started via startsImmediately there's assertions when the application state switches from foreground active to something else.

Reproducing project

As mentioned above one can use SyncUps for this with the only modification being the startsImmediately: false.

SQLiteData version information

main

Sharing version information

No response

GRDB version information

No response

Destination operating system

No response

Xcode version information

No response

Swift Compiler version information

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions