You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading Node to the latest version my application stopped working properly even though there were no code changes.
I could trace it down to the function withConnection that did not return at all, no errors, app seemed to hold there.
After downgrading Node to the latest stable version (v12.16.3) it worked again as expected.
Here is the code:
moduleEventStorewhereimportPreludeimportControl.Monad.Except.Trans (classMonadError, ExceptT, runExceptT, withExceptT)
importData.Argonaut (classEncodeJson, Json, jsonEmptyObject)
importData.Argonaut.Encode.Combinators ((:=), (~>))
importData.Either (Either(..))
importData.Maybe (Maybe(..))
importData.Tuple.Nested ((/\))
importDatabase.PostgreSQL.PG (classFromSQLRow, Connection, PGError, Pool, Query(Query), defaultPoolConfiguration, fromSQLValue, newPool, query)
importDatabase.PostgreSQL.PGasPGimportEffect.Aff (Aff)
importEffect.Aff.Class (classMonadAff)
importEffect.Class (liftEffect)
importTypes (EventId(..), Result, Limit(..))
typeEventStore={events::EventId->Limit->Result (ArrayEvent) }newtypeEvent=Event{id::EventId
, data::Json}instanceeventToJson :: EncodeJsonEventwhere
encodeJson (Event event) =
"offset" := unwrap event.id
~> ("payload" := event.data)
~> jsonEmptyObject
where
unwrap (EventId id) = id
instancefromSQLRowFoo :: FromSQLRowEventwhere
fromSQLRow [ idValue, dataValue ] = (\id data' ->Event { id: EventId id, data: data' }) <$> fromSQLValue idValue <*> fromSQLValue dataValue
fromSQLRow _ = Left"Expecting exactly two more fields."typePGa=ExceptTPGErrorAffawithConnection::∀a. Pool-> (Connection->PGa) ->PGa
withConnection = PG.withConnection runExceptT
newtypeDbName=DbNameStringnewtypeDbUser=DbUserStringnewtypeDbPass=DbPassStringnewtypeDbHost=DbHostStringeventStore::DbHost->DbName->DbUser->DbPass->ResultEventStore
eventStore (DbHost host) (DbName name) (DbUser user) (DbPass pass) = do
pool <- liftEffect $ newPool config
pure { events: \id limit -> withExceptT show $ withConnection pool (events id limit) }
where
config =
(defaultPoolConfiguration name)
{ idleTimeoutMillis = Just1000
, user = Just user
, password = Just pass
, host = Just host
, max = Just2
}
events::∀m. Bindm=>MonadErrorPGErrorm=>MonadAffm=>EventId->Limit->Connection->m (ArrayEvent)
events (EventId id) (Limit limit) conn = query conn (Query sql) (id /\ limit)
where
sql =
""" SELECT id, data FROM events WHERE id > $1 ORDER BY id ASC LIMIT $2"""
The text was updated successfully, but these errors were encountered:
After upgrading Node to the latest version my application stopped working properly even though there were no code changes.
I could trace it down to the function
withConnection
that did not return at all, no errors, app seemed to hold there.After downgrading Node to the latest stable version (
v12.16.3
) it worked again as expected.Here is the code:
The text was updated successfully, but these errors were encountered: