From a68dc8065873add2715974f2b6b44ac367af1b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Wed, 29 Apr 2026 05:05:54 +0200 Subject: [PATCH] Fix --- packages/effect-fc/src/SubmittableForm.ts | 62 ++++++++++++----------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/packages/effect-fc/src/SubmittableForm.ts b/packages/effect-fc/src/SubmittableForm.ts index 8bb6107..874ce6c 100644 --- a/packages/effect-fc/src/SubmittableForm.ts +++ b/packages/effect-fc/src/SubmittableForm.ts @@ -55,41 +55,43 @@ extends Pipeable.Class() implements SubmittableForm { } get run(): Effect.Effect { - return this.runSemaphore.withPermits(1)(Stream.runForEach( - this.encodedValue.changes, + return this.runSemaphore.withPermits(1)(Effect.provide( + Stream.runForEach( + this.encodedValue.changes, - encodedValue => Lens.get(this.validationFiber).pipe( - Effect.andThen(Option.match({ - onSome: Fiber.interrupt, - onNone: () => Effect.void, - })), - Effect.andThen( - Effect.forkScoped(Effect.onExit( - Schema.decode(this.schema, { errors: "all" })(encodedValue), - exit => Effect.andThen( - Exit.matchEffect(exit, { - onSuccess: v => Effect.andThen( - Lens.set(this.value, Option.some(v)), - Lens.set(this.issues, Array.empty()), - ), - onFailure: c => Option.match(Chunk.findFirst(Cause.failures(c), e => e._tag === "ParseError"), { - onSome: e => Effect.flatMap( - ParseResult.ArrayFormatter.formatError(e), - v => Lens.set(this.issues, v), + encodedValue => Lens.get(this.validationFiber).pipe( + Effect.andThen(Option.match({ + onSome: Fiber.interrupt, + onNone: () => Effect.void, + })), + Effect.andThen( + Effect.forkScoped(Effect.onExit( + Schema.decode(this.schema, { errors: "all" })(encodedValue), + exit => Effect.andThen( + Exit.matchEffect(exit, { + onSuccess: v => Effect.andThen( + Lens.set(this.value, Option.some(v)), + Lens.set(this.issues, Array.empty()), ), - onNone: () => Effect.void, + onFailure: c => Option.match(Chunk.findFirst(Cause.failures(c), e => e._tag === "ParseError"), { + onSome: e => Effect.flatMap( + ParseResult.ArrayFormatter.formatError(e), + v => Lens.set(this.issues, v), + ), + onNone: () => Effect.void, + }), }), - }), - Lens.set(this.validationFiber, Option.none()), - ), - )).pipe( - Effect.tap(fiber => Lens.set(this.validationFiber, Option.some(fiber))), - Effect.andThen(Fiber.join), - Effect.forkScoped, - ) + Lens.set(this.validationFiber, Option.none()), + ), + )) + ), + Effect.tap(fiber => Lens.set(this.validationFiber, Option.some(fiber))), + Effect.andThen(Fiber.join), + Effect.ignore, ), - Effect.provide(this.context), ), + + this.context, )) }