Closed JonathanHopeDMRC closed 1 year ago
Hey 👋
Some other NPM packages that have similar aims like Slonik support retrying transactions/queries.
Slonik's aim seems to be node-postgres
on steroids with some type-safety.
Kysely's aim is primarily to be a type-safe sql query builder. It also does other things like execution, migrations, etc.
I can't find anything about retries in the kysely docs. Is there any plan to add support for retries to kysely
Not that I know of. Thanks for submitting this issue. There is some intent to provide more fine-grained control with transactions @ #257, that might make it easier for consumers to implement their own retry mechanisms.
is there a recommended approach using third party packages?
I'd probably try this library.
For query retries, I'd write a custom driver that extends a built-in driver and overrides query execution like:
async override executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>> {
try {
return await backoff(() => super.executeQuery(compiledQuery));
} catch (error: unknown) {
// ...
}
}
I think this is a little out of scope for a query builder. As @igalklebanov mentioned, a custom wrapper for your dialect is only some tens of lines of code and would suit well in this situation.
Some other NPM packages that have similar aims like Slonik support retrying transactions/queries. I can't find anything about retries in the kysely docs. Is there any plan to add support for retries to kysely, or is there a recommended approach using third party packages?
Thanks!