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:
Julius Marminge committed 2026-03-25 22:59:34 -07:00
1 parent 9934b6ea76
commit e39cf66e60
1 file changed
+2 -3
+2 -3
View File
@@ -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);