Make server settings startup atomic
- Guard `start()` with an atomic started flag - Await the existing deferred when startup has already begun
This commit is contained in:
1 parent
9934b6ea76
commit
e39cf66e60
1 file changed
+2
-3
@@ -285,12 +285,11 @@ const makeServerSettings = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
const start = Effect.gen(function* () {
|
||||
const alreadyStarted = yield* Ref.get(startedRef);
|
||||
if (alreadyStarted) {
|
||||
const shouldStart = yield* Ref.modify(startedRef, (started) => [!started, true]);
|
||||
if (!shouldStart) {
|
||||
return yield* Deferred.await(startedDeferred);
|
||||
}
|
||||
|
||||
yield* Ref.set(startedRef, true);
|
||||
const startup = Effect.gen(function* () {
|
||||
yield* startWatcher;
|
||||
yield* Cache.invalidate(settingsCache, cacheKey);
|
||||
|
||||
Reference in new issue
Block a user