fix: writable issue

This commit is contained in:
orion 2024-07-17 13:26:44 -05:00
parent b2bac919ba
commit 5c680ac55f
Signed by: orion
GPG Key ID: 6D4165AE4C928719

View File

@ -191,9 +191,17 @@ awaitReadableOrClosed s = Aff.supervise do
awaitFinished :: forall s a. Write s a => s -> Aff Unit awaitFinished :: forall s a. Write s a => s -> Aff Unit
awaitFinished s = Aff.supervise do awaitFinished s = Aff.supervise do
fiber <- Aff.forkAff $ onceAff0 finishH s fiber <-
Aff.forkAff
$ parOneOf
[ onceAff0 finishH s $> Right unit
, Left <$> onceAff1 errorH s
]
finished <- liftEffect $ isWritableFinished s finished <- liftEffect $ isWritableFinished s
if not finished then Aff.joinFiber fiber else Aff.killFiber (error "") fiber if not finished then
liftEither =<< Aff.joinFiber fiber
else
Aff.killFiber (error "") fiber
awaitWritableOrClosed :: forall s a. Write s a => s -> Aff Unit awaitWritableOrClosed :: forall s a. Write s a => s -> Aff Unit
awaitWritableOrClosed s = Aff.supervise do awaitWritableOrClosed s = Aff.supervise do