File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
packages/react-hooks/src/hooks
references/hello-world/src/trigger Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -591,7 +591,7 @@ async function processRealtimeBatch<TTask extends AnyTask = AnyTask>(
591
591
}
592
592
}
593
593
594
- // Inserts and then orders by the run number , and ensures that the run is not duplicated
594
+ // Inserts and then orders by the run createdAt timestamp , and ensures that the run is not duplicated
595
595
function insertRunShapeInOrder < TTask extends AnyTask > (
596
596
previousRuns : RealtimeRun < TTask > [ ] ,
597
597
run : RealtimeRun < TTask >
@@ -601,8 +601,8 @@ function insertRunShapeInOrder<TTask extends AnyTask>(
601
601
return previousRuns . map ( ( r ) => ( r . id === run . id ? run : r ) ) ;
602
602
}
603
603
604
- const runNumber = run . number ;
605
- const index = previousRuns . findIndex ( ( r ) => r . number > runNumber ) ;
604
+ const runCreatedAt = run . createdAt ;
605
+ const index = previousRuns . findIndex ( ( r ) => r . createdAt > runCreatedAt ) ;
606
606
if ( index === - 1 ) {
607
607
return [ ...previousRuns , run ] ;
608
608
}
Original file line number Diff line number Diff line change
1
+ import { logger , runs , task } from "@trigger.dev/sdk" ;
2
+
3
+ export const statusesTest = task ( {
4
+ id : "statuses-test" ,
5
+ run : async ( ) => {
6
+ console . log ( "statusesTest" ) ;
7
+ } ,
8
+ } ) ;
9
+
10
+ export const subscribeToRun = task ( {
11
+ id : "subscribe-to-run" ,
12
+ run : async ( payload : { runId : string } ) => {
13
+ const subscription = runs . subscribeToRun ( payload . runId , {
14
+ stopOnCompletion : false ,
15
+ } ) ;
16
+
17
+ for await ( const event of subscription ) {
18
+ logger . info ( "run event" , { event } ) ;
19
+ }
20
+ } ,
21
+ } ) ;
22
+
23
+ export const retrieveRun = task ( {
24
+ id : "retrieve-run" ,
25
+ run : async ( payload : { runId : string } ) => {
26
+ const run = await runs . retrieve ( payload . runId ) ;
27
+ logger . info ( "run" , { run } ) ;
28
+ } ,
29
+ } ) ;
You can’t perform that action at this time.
0 commit comments