Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

sumerman
Copy link
Contributor

@sumerman sumerman commented Sep 17, 2025

  • This PR attempts to catch and wrap errors originating from ClickHouse in order provide guidance to users.
  • Error codes between public api and UI are different. UI has handling for a non-standard 524 that suits this case better. While in the public API I chose to stick with a more common HTTP error code.
  • I added a suite that exercises overall withMiddlewares error handling behaviour.

Important

Improves ClickHouse memory error handling by introducing ClickHouseResourceError and updating error handling logic in clickhouse.ts, withMiddlewares.ts, and trpc.ts, with corresponding tests added.

  • Error Handling:
    • Introduces ClickHouseResourceError class in clickhouse.ts to handle memory, overcommit, and timeout errors.
    • Updates queryClickhouse, queryClickhouseStream, and commandClickhouse in clickhouse.ts to wrap errors using ClickHouseResourceError.wrapIfResourceError().
    • Modifies withMiddlewares.ts to handle ClickHouseResourceError by returning a 524 status code with advice message.
    • Updates trpc.ts middleware to handle ClickHouseResourceError by setting a TIMEOUT error code with advice message.
  • Testing:
    • Adds clickhouse-resource-errors.servertest.ts to test error transformation for ClickHouse errors.
    • Adds withMiddlewares.servertest.ts to test error handling in withMiddlewares function.
  • Misc:
    • Adds advice message for ClickHouse errors in withMiddlewares.ts and trpc.ts.

This description was created by Ellipsis for b39813b. You can customize this summary. It will automatically update as commits are pushed.

@sumerman sumerman force-pushed the valeriy/lfe-4598-ch-errors-for-humans branch 3 times, most recently from c11c58d to 6917b04 Compare September 17, 2025 16:18
@sumerman sumerman marked this pull request as ready for review September 17, 2025 16:18
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug Something isn't working labels Sep 17, 2025
@sumerman sumerman force-pushed the valeriy/lfe-4598-ch-errors-for-humans branch 2 times, most recently from 945464e to 796b6af Compare September 17, 2025 16:29
@maxdeichmann
Copy link
Member

One more thought: we should show the public API docs only for errors in the public API or drop the reference to the docs if easier.

@sumerman
Copy link
Contributor Author

One more thought: we should show the public API docs only for errors in the public API or drop the reference to the docs if easier.

From what I understand so far, tRPC doesn't go through withMiddlewares. What else is there other than public API and tRPC?

@sumerman sumerman force-pushed the valeriy/lfe-4598-ch-errors-for-humans branch from 84388df to edc17b3 Compare September 18, 2025 11:44
@Steffen911
Copy link
Member

From what I understand so far, tRPC doesn't go through withMiddlewares. What else is there other than public API and tRPC?

I think this would cover sufficient cases. After a week of this being in place we could just scan through our spans and see if there are any that still raised this up to the user.

Copy link
Member

We resolved this in person.

@sumerman sumerman force-pushed the valeriy/lfe-4598-ch-errors-for-humans branch from edc17b3 to b39813b Compare September 18, 2025 22:32
@sumerman sumerman added the auto-merge This PR is set to be merged label Sep 18, 2025
@sumerman sumerman added this pull request to the merge queue Sep 18, 2025
Merged via the queue into main with commit f4caaca Sep 18, 2025
30 checks passed
@sumerman sumerman deleted the valeriy/lfe-4598-ch-errors-for-humans branch September 18, 2025 22:50
@dosubot dosubot bot removed the auto-merge This PR is set to be merged label Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants