@@ -184,41 +184,42 @@ export class RepoInitWorkflow extends WorkflowEntrypoint<Env, RepoInitParams> {
184184 ) ;
185185 await Promise . all (
186186 issueIdsArray . map ( async ( issueIds ) => {
187- const embeddingWorkflowId = await step . do (
187+ await step . do (
188188 "call worker to create and insert embeddings" ,
189189 async ( ) => {
190- return await this . env . SYNC_EMBEDDING_WORKFLOW . create ( {
191- id : generateSyncWorkflowId (
192- `embedding-${ repoOwner } -${ repoName } ` ,
193- ) ,
194- params : {
195- mode : "init" ,
196- issueIds,
197- repoName,
198- repoId,
199- } ,
200- } ) ;
190+ const embeddingWorkflowId =
191+ await this . env . SYNC_EMBEDDING_WORKFLOW . create ( {
192+ id : generateSyncWorkflowId (
193+ `embedding-${ repoOwner } -${ repoName } ` ,
194+ ) ,
195+ params : {
196+ mode : "init" ,
197+ issueIds,
198+ repoName,
199+ repoId,
200+ } ,
201+ } ) ;
202+ while ( true ) {
203+ await step . sleep (
204+ "wait for worker to finish" ,
205+ PARENT_WORKER_SLEEP_DURATION ,
206+ ) ;
207+ const { status } =
208+ await this . env . SYNC_EMBEDDING_WORKFLOW . getInstanceStatus (
209+ embeddingWorkflowId ,
210+ ) ;
211+ if ( status === "complete" ) {
212+ return ;
213+ }
214+ // if the children workflow has errored out, it should be a terminal state and we should throw an error here
215+ // that would force a retry
216+ // however, I have observed that an errored out workflow can still continue to run (wtf)
217+ if ( status === "errored" || status === "terminated" ) {
218+ throw new Error ( "Embedding worker failed, retrying now" ) ;
219+ }
220+ }
201221 } ,
202222 ) ;
203- while ( true ) {
204- await step . sleep (
205- "wait for worker to finish" ,
206- PARENT_WORKER_SLEEP_DURATION ,
207- ) ;
208- const { status } =
209- await this . env . SYNC_EMBEDDING_WORKFLOW . getInstanceStatus (
210- embeddingWorkflowId ,
211- ) ;
212- if ( status === "complete" ) {
213- return ;
214- }
215- // if the children workflow has errored out, it should be a terminal state and we should throw an error here
216- // that would force a retry
217- // however, I have observed that an errored out workflow can still continue to run (wtf)
218- if ( status === "errored" || status === "terminated" ) {
219- throw new Error ( "Embedding worker failed, retrying now" ) ;
220- }
221- }
222223 } ) ,
223224 ) ;
224225 await step . do (
0 commit comments