Skip to content

fix: handle ObjectBox intra-process double-open on Linux desktop#3021

Open
ManavA wants to merge 1 commit into
BlueBubblesApp:developmentfrom
ManavA:manav/fix/objectbox-intra-process-attach
Open

fix: handle ObjectBox intra-process double-open on Linux desktop#3021
ManavA wants to merge 1 commit into
BlueBubblesApp:developmentfrom
ManavA:manav/fix/objectbox-intra-process-attach

Conversation

@ManavA
Copy link
Copy Markdown

@ManavA ManavA commented May 8, 2026

Problem

`_initDatabaseDesktop` distinguishes between cross-process (Linux: signal the running instance and exit) and intra-process (Windows: `Store.attach`) collisions when `openStore()` fails. but on Linux, when an isolate or another entry point in the same process opens the store first, the main thread's `openStore()` raises:

```
another store is still open using the same path
```

…which currently falls into the `Platform.isLinux` branch and silently `exit(0)`s the app — even though there's no second process to signal. `_initDatabaseMobile` already handles this case correctly with `Store.isOpen()` + attach; desktop didn't.

Solution

  • check `Store.isOpen()` upfront and attach if true (mirroring `_initDatabaseMobile`)
  • in the catch, treat the "another store is still open" exception as the intra-process signal regardless of platform, attaching to the existing store
  • the `Platform.isLinux` exit path now only fires for genuine cross-process collisions (i.e. a different running instance owns the LMDB lock)

Testing

  • Linux desktop: the exit-on-isolate-collision regression is gone; main thread now attaches cleanly
  • second-instance launch on Linux still triggers the signal-and-exit path correctly (the foreground hand-off works as before)
  • Windows: behaviour unchanged — same exception string, now matched by the platform-agnostic branch instead of the `Platform.isWindows` one

`_initDatabaseDesktop` only handled the cross-process case (Linux: signal-and-exit) and the Windows isolate case (attach). on Linux when an isolate or background entry point opens the store first, the main thread's `openStore()` throws "another store is still open using the same path" — which falls into the Linux branch and exits the app.

restructure to check `Store.isOpen()` upfront (attach if so), and treat the "another store is still open" exception as the intra-process signal regardless of platform. Linux's exit-and-signal path now only runs for genuine cross-process collisions. mirrors what `_initDatabaseMobile` already does.
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.

1 participant