# Prevent duplicate instances by coordinating via a socket \(\#2691\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/da7dce79f6ce81c16908194740f2fec1599ab17f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: da7dce79f6ce81c16908194740f2fec1599ab17f

Requested commit: da7dce79f6ce81c16908194740f2fec1599ab17f

Commit: da7dce79f6ce81c16908194740f2fec1599ab17f

Tree: 6a9ed96250a4c80f1c1d85d9f4b3076f9e4bdd7d

Author: Julia

Committer: GitHub

## Message

```
Prevent duplicate instances by coordinating via a socket (#2691)

We've been getting a bunch of panics from duplicate app instances
competing over the local sqlite DB. After chatting with @mikayla-maki we
determined it was probably best to add our own mechanism to prevent
duplicates rather than just relying on the OS. My logic is that we'd
need to build a system like this eventually for Windows/Linux anyway so
it's more appealing than reworking our local DB access to be able to
cooperate with another process while likely isn't something we want to
support anyway.

I attempted to keep this mechanism conservative so in the case of
another program interfering with it we should fail somewhat gracefully
and still continue to launch, albeit without the ability to prevent
another instance from launching.

Fixes
https://linear.app/zed-industries/issue/Z-2435/thread-background-executor-1-panicked-at-could-not-send-write-action

Release Notes:
- Added a mechanism to prevent duplicate Zed instances from launching to
avoid a crash.
```

## Parents

- [abf3b4a54e66e0a67cc39c2b6454d89ab7295534](https://git.cafe/gitcafe/zed/commit/abf3b4a54e66e0a67cc39c2b6454d89ab7295534?format=markdown)

- [caa29d57c2d82fbbcdc2f7d7ef6ec1d39969767c](https://git.cafe/gitcafe/zed/commit/caa29d57c2d82fbbcdc2f7d7ef6ec1d39969767c?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/da7dce79f6ce81c16908194740f2fec1599ab17f?format=markdown)
