Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmp-postgres fails with uncaught exception: StartError StartPostgresFailed (ExitFailure 1) #278

Open
tonyalaribe opened this issue Jun 9, 2023 · 1 comment

Comments

@tonyalaribe
Copy link

Any chance we get more detailed errors?

I've been getting the following crash when I try to run a test with tmp-postgres.

       uncaught exception: StartError
       StartPostgresFailed (ExitFailure 1)

The error doesn't give me any information about what I'm doing wrong, so I have no idea how to proceed other than trying different random things in my hspec withSetup implmentation.

A have a withSetup configured as follows:

withSetup :: (Pool Connection -> IO ()) -> IO ()
withSetup f = do
  -- Helper to throw exceptions
  let throwE x = either throwIO pure =<< x

  throwE $ withDbCache $ \dbCache -> withConfig (cacheConfig dbCache) $ \db -> do
    conn <- liftIO $ connectPostgreSQL (TmpPostgres.toConnectionString db)
    initializationRes <- Migrations.runMigration conn Migrations.defaultOptions MigrationInitialization
    x <- withSnapshot db $ \snapshot -> do
      withConfig (snapshotConfig snapshot) $ \migratedDb -> f =<< createPool (connectPostgreSQL $ toConnectionString migratedDb) close 2 60 10
    pTraceShowM x 
    pass
    ```
@tonyalaribe
Copy link
Author

Making progress on this, it seems
getInitDbVersion panics on this line:

theLastPart = last $ words outputString
versionPart = takeWhile (\x -> isDigit x || x == '.' || x == '-') theLastPart
humanReadable = if last versionPart == '.'
        then init versionPart
        else versionPart

initdb --version is

initdb (PostgreSQL) 14.8 (Homebrew)

on my machine. So the last part is not the version. So last results in a crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant