Skip to content

fix(adapter-pg): Add handling of socket and TLS level errors - #27682

Merged
jacek-prisma merged 1 commit into
prisma:mainfrom
barryhagan:adapter_pg_socket_error
Jul 23, 2025
Merged

jacek-prisma merged 1 commit into
prisma:mainfrom
barryhagan:adapter_pg_socket_error

Conversation

@barryhagan

@barryhagan barryhagan commented Jul 17, 2025 •

Copy link
Copy Markdown
Contributor

Add the missing mappings from adapter-pg to Prisma errors P1001, P1011, and P1017.

This doesn't completely resolve #27626, but it makes the error codes on queries correct for connection level issues.

@barryhagan

Copy link
Copy Markdown
Contributor Author

failing e2e is because this will need an update in prisma-engines to handle the DriverAdapterError mappings. I guess DatabaseNotReachable, TlsConnectionError, and ConnectionClosed were never a thing for adapters even though they have Prisma error codes.

@jacek-prisma

Copy link
Copy Markdown
Contributor

Hi @barryhagan, this change requires a minor adjustment in prisma-engines, the new variants need to be added to this data type:
https://github.com/prisma/prisma-engines/blob/8ffdf9be03ef5d01959364990a78e7f816d6dc0b/libs/driver-adapters/src/error.rs#L55
Then, they need to be mapped here:
https://github.com/prisma/prisma-engines/blob/8ffdf9be03ef5d01959364990a78e7f816d6dc0b/libs/driver-adapters/src/lib.rs#L28

After the prisma-engines change is ready you can run the tests against the prisma-engines branch by adding /engine-branch my-branch-name to the description of this PR.

@barryhagan

Copy link
Copy Markdown
Contributor Author

You may have a bigger issue at hand with your CI job and e2e tests. The use of a custom engine branch is not obeyed when running e2e tests in docker containers. The PRISMA_QUERY_ENGINE_BINARY env var is not supplied and it doesn't look like you add a volume to mount/target/release.

So this e2e test will fail until the engine PR is merged.

I added version output to the failing test to prove that even though the custom branch from my pull was built (bff345156758e55d5c51d6eaf300c3714808f13b), the e2e test is still using the default resolved engine (0b2e493791181e99e767ee7c566626d82da01481)

https://github.com/prisma/prisma/actions/runs/16390247346/job/46315265533#step:5:6296

@aqrln

aqrln commented Jul 21, 2025

Copy link
Copy Markdown
Member

You may have a bigger issue at hand with your CI job and e2e tests. The use of a custom engine branch is not obeyed when running e2e tests in docker containers. The PRISMA_QUERY_ENGINE_BINARY env var is not supplied and it doesn't look like you add a volume to mount/target/release.

Ouch, yeah, you are right, very good catch. I think you could make this test pass in the PR by switching it to use queryCompiler or WASM query engine (assuming it won't cause any other problems in this test). But it's also fine to just merge the engines PR first.

jacek-prisma pushed a commit to prisma/prisma-engines that referenced this pull request Jul 22, 2025
Support needed for prisma/orm#27682

Mapping these to RawConnectorError, because the other paths through
NativeErrorKind were going to be ugly. Selfishly, this is really only to
improve the behavior of queryCompiler + driverAdapters.
@barryhagan
barryhagan force-pushed the adapter_pg_socket_error branch from cdf7ef3 to 785d8ec Compare July 23, 2025 10:25
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

Successfully merging this pull request may close these issues.

adapter-pg doesn't properly handle DB connection errors

3 participants