Skip to content

Commit

Permalink
fix: handle 0 discussions (#9682)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick committed Apr 29, 2024
1 parent b28ccc2 commit cedc91c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/embedder/EmbeddingsJobQueueStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class EmbeddingsJobQueueStream implements AsyncIterableIterator<DBJob> {
.orderBy(['priority'])
.$if(!isFailed, (db) => db.where('state', '=', 'queued'))
.$if(isFailed, (db) =>
db.where('state', '=', 'failed').where('retryAfter', '<', new Date())
db
.where('state', '=', 'failed')
.where('retryAfter', 'is not', null)
.where('retryAfter', '<', new Date())
)
.limit(1)
.forUpdate()
Expand Down
2 changes: 1 addition & 1 deletion packages/embedder/WorkflowOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class WorkflowOrchestrator {
Logger.error(error)
const pg = getKysely()
const {message, retryDelay, jobData} = error
const maxRetries = error.maxRetries ?? 1e6
const maxRetries = error.maxRetries ?? 10
await pg
.updateTable('EmbeddingsJobQueue')
.set((eb) => ({
Expand Down
1 change: 1 addition & 0 deletions packages/embedder/workflows/relatedDiscussionsStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const relatedDiscussionsStart: JobQueueStepRun<
// Not techincally updatedAt since discussions are updated after they get created
refUpdatedAt: createdAt
}))
if (metadataRows.length === 0) return false
const inserts = await pg
.insertInto('EmbeddingsMetadata')
.values(metadataRows)
Expand Down

0 comments on commit cedc91c

Please sign in to comment.