PR comments.

This commit is contained in:
mike12345567 2024-07-11 16:41:12 +01:00
parent 1e189450c0
commit 5b1850d28f
1 changed files with 4 additions and 3 deletions

View File

@ -249,7 +249,7 @@ function resyncDefinitionsRequired(status: number, message: string) {
export async function search( export async function search(
options: RowSearchParams, options: RowSearchParams,
table: Table, table: Table,
opts?: { retry?: boolean } opts?: { retries?: number }
): Promise<SearchResponse<Row>> { ): Promise<SearchResponse<Row>> {
let { paginate, query, ...params } = options let { paginate, query, ...params } = options
@ -374,9 +374,10 @@ export async function search(
return response return response
} catch (err: any) { } catch (err: any) {
const msg = typeof err === "string" ? err : err.message const msg = typeof err === "string" ? err : err.message
if (!opts?.retry && resyncDefinitionsRequired(err.status, msg)) { const firstTry = !opts?.retries || opts.retries === 0
if (firstTry && resyncDefinitionsRequired(err.status, msg)) {
await sdk.tables.sqs.syncDefinition() await sdk.tables.sqs.syncDefinition()
return search(options, table, { retry: true }) return search(options, table, { retries: 1 })
} }
// previously the internal table didn't error when a column didn't exist in search // previously the internal table didn't error when a column didn't exist in search
if (err.status === 400 && msg?.match(MISSING_COLUMN_REGEX)) { if (err.status === 400 && msg?.match(MISSING_COLUMN_REGEX)) {