-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathdev-run-controller.ts
More file actions
831 lines (684 loc) · 22.9 KB
/
dev-run-controller.ts
File metadata and controls
831 lines (684 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
import {
CompleteRunAttemptResult,
DequeuedMessage,
IntervalService,
LogLevel,
RunExecutionData,
TaskRunExecution,
TaskRunExecutionMetrics,
TaskRunExecutionResult,
TaskRunFailedExecutionResult,
} from "@trigger.dev/core/v3";
import { type WorkloadRunAttemptStartResponseBody } from "@trigger.dev/core/v3/workers";
import { setTimeout as sleep } from "timers/promises";
import { CliApiClient } from "../apiClient.js";
import { TaskRunProcess } from "../executions/taskRunProcess.js";
import { assertExhaustive } from "../utilities/assertExhaustive.js";
import { logger } from "../utilities/logger.js";
import { sanitizeEnvVars } from "../utilities/sanitizeEnvVars.js";
import { join } from "node:path";
import { BackgroundWorker } from "../dev/backgroundWorker.js";
import { eventBus } from "../utilities/eventBus.js";
type DevRunControllerOptions = {
runFriendlyId: string;
worker: BackgroundWorker;
httpClient: CliApiClient;
logLevel: LogLevel;
heartbeatIntervalSeconds?: number;
onSubscribeToRunNotifications: (run: Run, snapshot: Snapshot) => void;
onUnsubscribeFromRunNotifications: (run: Run, snapshot: Snapshot) => void;
onFinished: () => void;
};
type Run = {
friendlyId: string;
attemptNumber?: number | null;
};
type Snapshot = {
friendlyId: string;
};
export class DevRunController {
private taskRunProcess?: TaskRunProcess;
private readonly worker: BackgroundWorker;
private readonly httpClient: CliApiClient;
private readonly runHeartbeat: IntervalService;
private readonly heartbeatIntervalSeconds: number;
private readonly snapshotPoller: IntervalService;
private readonly snapshotPollIntervalSeconds: number;
private state:
| {
phase: "RUN";
run: Run;
snapshot: Snapshot;
}
| {
phase: "IDLE" | "WARM_START";
} = { phase: "IDLE" };
private enterRunPhase(run: Run, snapshot: Snapshot) {
this.onExitRunPhase(run);
this.state = { phase: "RUN", run, snapshot };
this.runHeartbeat.start();
this.snapshotPoller.start();
}
constructor(private readonly opts: DevRunControllerOptions) {
logger.debug("[DevRunController] Creating controller", {
run: opts.runFriendlyId,
});
this.worker = opts.worker;
this.heartbeatIntervalSeconds = opts.heartbeatIntervalSeconds || 20;
this.snapshotPollIntervalSeconds = 5;
this.httpClient = opts.httpClient;
this.snapshotPoller = new IntervalService({
onInterval: async () => {
if (!this.runFriendlyId) {
logger.debug("[DevRunController] Skipping snapshot poll, no run ID");
return;
}
logger.debug("[DevRunController] Polling for latest snapshot");
this.httpClient.dev.sendDebugLog(this.runFriendlyId, {
time: new Date(),
message: `snapshot poll: started`,
properties: {
snapshotId: this.snapshotFriendlyId,
},
});
const response = await this.httpClient.dev.getRunExecutionData(this.runFriendlyId);
if (!response.success) {
logger.debug("[DevRunController] Snapshot poll failed", { error: response.error });
this.httpClient.dev.sendDebugLog(this.runFriendlyId, {
time: new Date(),
message: `snapshot poll: failed`,
properties: {
snapshotId: this.snapshotFriendlyId,
error: response.error,
},
});
return;
}
await this.handleSnapshotChange(response.data.execution);
},
intervalMs: this.snapshotPollIntervalSeconds * 1000,
leadingEdge: false,
onError: async (error) => {
logger.debug("[DevRunController] Failed to poll for snapshot", { error });
},
});
this.runHeartbeat = new IntervalService({
onInterval: async () => {
if (!this.runFriendlyId || !this.snapshotFriendlyId) {
logger.debug("[DevRunController] Skipping heartbeat, no run ID or snapshot ID");
return;
}
logger.debug("[DevRunController] Sending heartbeat");
const response = await this.httpClient.dev.heartbeatRun(
this.runFriendlyId,
this.snapshotFriendlyId,
{
cpu: 0,
memory: 0,
}
);
if (!response.success) {
logger.debug("[DevRunController] Heartbeat failed", { error: response.error });
}
},
intervalMs: this.heartbeatIntervalSeconds * 1000,
leadingEdge: false,
onError: async (error) => {
logger.debug("[DevRunController] Failed to send heartbeat", { error });
},
});
process.on("SIGTERM", this.sigterm);
}
private async sigterm() {
logger.debug("[DevRunController] Received SIGTERM, stopping worker");
await this.stop();
}
// This should only be used when we're already executing a run. Attempt number changes are not allowed.
private updateRunPhase(run: Run, snapshot: Snapshot) {
if (this.state.phase !== "RUN") {
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `updateRunPhase: Invalid phase for updating snapshot: ${this.state.phase}`,
properties: {
currentPhase: this.state.phase,
snapshotId: snapshot.friendlyId,
},
});
throw new Error(`Invalid phase for updating snapshot: ${this.state.phase}`);
}
if (this.state.run.friendlyId !== run.friendlyId) {
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `updateRunPhase: Mismatched run IDs`,
properties: {
currentRunId: this.state.run.friendlyId,
newRunId: run.friendlyId,
currentSnapshotId: this.state.snapshot.friendlyId,
newSnapshotId: snapshot.friendlyId,
},
});
throw new Error("Mismatched run IDs");
}
if (this.state.snapshot.friendlyId === snapshot.friendlyId) {
logger.debug("updateRunPhase: Snapshot not changed", { run, snapshot });
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `updateRunPhase: Snapshot not changed`,
properties: {
snapshotId: snapshot.friendlyId,
},
});
return;
}
if (this.state.run.attemptNumber !== run.attemptNumber) {
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `updateRunPhase: Attempt number changed`,
properties: {
oldAttemptNumber: this.state.run.attemptNumber ?? undefined,
newAttemptNumber: run.attemptNumber ?? undefined,
},
});
throw new Error("Attempt number changed");
}
this.state = {
phase: "RUN",
run: {
friendlyId: run.friendlyId,
attemptNumber: run.attemptNumber,
},
snapshot: {
friendlyId: snapshot.friendlyId,
},
};
}
private onExitRunPhase(newRun: Run | undefined = undefined) {
// We're not in a run phase, nothing to do
if (this.state.phase !== "RUN") {
logger.debug("onExitRunPhase: Not in run phase, skipping", { phase: this.state.phase });
return;
}
// This is still the same run, so we're not exiting the phase
if (newRun?.friendlyId === this.state.run.friendlyId) {
logger.debug("onExitRunPhase: Same run, skipping", { newRun });
return;
}
logger.debug("onExitRunPhase: Exiting run phase", { newRun });
this.runHeartbeat.stop();
this.snapshotPoller.stop();
const { run, snapshot } = this.state;
this.unsubscribeFromRunNotifications({ run, snapshot });
}
private subscribeToRunNotifications({ run, snapshot }: { run: Run; snapshot: Snapshot }) {
logger.debug("[DevRunController] Subscribing to run notifications", { run, snapshot });
this.opts.onSubscribeToRunNotifications(run, snapshot);
}
private unsubscribeFromRunNotifications({ run, snapshot }: { run: Run; snapshot: Snapshot }) {
logger.debug("[DevRunController] Unsubscribing from run notifications", { run, snapshot });
this.opts.onUnsubscribeFromRunNotifications(run, snapshot);
}
private get runFriendlyId() {
if (this.state.phase !== "RUN") {
return undefined;
}
return this.state.run.friendlyId;
}
private get snapshotFriendlyId() {
if (this.state.phase !== "RUN") {
return;
}
return this.state.snapshot.friendlyId;
}
get workerFriendlyId() {
if (!this.opts.worker.serverWorker) {
throw new Error("No version for dev worker");
}
return this.opts.worker.serverWorker.id;
}
private handleSnapshotChangeLock = false;
private async handleSnapshotChange({
run,
snapshot,
completedWaitpoints,
}: Pick<RunExecutionData, "run" | "snapshot" | "completedWaitpoints">) {
if (this.handleSnapshotChangeLock) {
logger.debug("handleSnapshotChange: already in progress");
return;
}
this.handleSnapshotChangeLock = true;
// Reset the (fallback) snapshot poll interval so we don't do unnecessary work
this.snapshotPoller.resetCurrentInterval();
try {
if (!this.snapshotFriendlyId) {
logger.debug("handleSnapshotChange: Missing snapshot ID", {
runId: run.friendlyId,
snapshotId: this.snapshotFriendlyId,
});
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `snapshot change: missing snapshot ID`,
properties: {
newSnapshotId: snapshot.friendlyId,
newSnapshotStatus: snapshot.executionStatus,
},
});
return;
}
if (this.snapshotFriendlyId === snapshot.friendlyId) {
logger.debug("handleSnapshotChange: snapshot not changed, skipping", { snapshot });
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `snapshot change: skipping, no change`,
properties: {
snapshotId: this.snapshotFriendlyId,
snapshotStatus: snapshot.executionStatus,
},
});
return;
}
logger.debug(`handleSnapshotChange: ${snapshot.executionStatus}`, {
run,
oldSnapshotId: this.snapshotFriendlyId,
newSnapshot: snapshot,
completedWaitpoints: completedWaitpoints.length,
});
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `snapshot change: ${snapshot.executionStatus}`,
properties: {
oldSnapshotId: this.snapshotFriendlyId,
newSnapshotId: snapshot.friendlyId,
completedWaitpoints: completedWaitpoints.length,
},
});
try {
this.updateRunPhase(run, snapshot);
} catch (error) {
logger.debug("handleSnapshotChange: failed to update run phase", {
run,
snapshot,
error,
});
this.runFinished();
return;
}
switch (snapshot.executionStatus) {
case "PENDING_CANCEL": {
try {
await this.cancelAttempt();
} catch (error) {
logger.debug("Failed to cancel attempt, killing task run process", {
error,
});
try {
await this.taskRunProcess?.kill("SIGKILL");
} catch (error) {
logger.debug("Failed to cancel attempt, failed to kill task run process", { error });
}
return;
}
return;
}
case "FINISHED": {
logger.debug("Run is finished, nothing to do");
return;
}
case "EXECUTING_WITH_WAITPOINTS": {
logger.debug("Run is executing with waitpoints", { snapshot });
try {
await this.taskRunProcess?.cleanup(false);
} catch (error) {
logger.debug("Failed to cleanup task run process", { error });
}
if (snapshot.friendlyId !== this.snapshotFriendlyId) {
logger.debug("Snapshot changed after cleanup, abort", {
oldSnapshotId: snapshot.friendlyId,
newSnapshotId: this.snapshotFriendlyId,
});
return;
}
//no snapshots in DEV, so we just return.
return;
}
case "SUSPENDED": {
logger.debug("Run shouldn't be suspended in DEV", {
run,
snapshot,
});
return;
}
case "PENDING_EXECUTING": {
logger.debug("Run is pending execution", { run, snapshot });
if (completedWaitpoints.length === 0) {
logger.log("No waitpoints to complete, nothing to do");
return;
}
logger.debug("Run shouldn't be PENDING_EXECUTING with completedWaitpoints in DEV", {
run,
snapshot,
});
return;
}
case "EXECUTING": {
logger.debug("Run is now executing", { run, snapshot });
if (completedWaitpoints.length === 0) {
return;
}
logger.debug("Processing completed waitpoints", { completedWaitpoints });
if (!this.taskRunProcess) {
logger.debug("No task run process, ignoring completed waitpoints", {
completedWaitpoints,
});
return;
}
for (const waitpoint of completedWaitpoints) {
this.taskRunProcess.waitpointCompleted(waitpoint);
}
return;
}
case "RUN_CREATED":
case "QUEUED_EXECUTING":
case "QUEUED": {
logger.debug("Status change not handled", { status: snapshot.executionStatus });
return;
}
default: {
assertExhaustive(snapshot.executionStatus);
}
}
} catch (error) {
logger.debug("handleSnapshotChange: unexpected error", { error });
this.httpClient.dev.sendDebugLog(run.friendlyId, {
time: new Date(),
message: `snapshot change: unexpected error`,
properties: {
snapshotId: snapshot.friendlyId,
error: error instanceof Error ? error.message : String(error),
},
});
} finally {
this.handleSnapshotChangeLock = false;
}
}
private async startAndExecuteRunAttempt({
runFriendlyId,
snapshotFriendlyId,
dequeuedAt,
isWarmStart = false,
}: {
runFriendlyId: string;
snapshotFriendlyId: string;
dequeuedAt?: Date;
isWarmStart?: boolean;
}) {
this.subscribeToRunNotifications({
run: { friendlyId: runFriendlyId },
snapshot: { friendlyId: snapshotFriendlyId },
});
const attemptStartedAt = Date.now();
const start = await this.httpClient.dev.startRunAttempt(runFriendlyId, snapshotFriendlyId);
if (!start.success) {
logger.debug("[DevRunController] Failed to start run", { error: start.error });
this.runFinished();
return;
}
const attemptDuration = Date.now() - attemptStartedAt;
const { run, snapshot, execution, envVars } = start.data;
eventBus.emit("runStarted", this.opts.worker, execution);
logger.debug("[DevRunController] Started run", {
runId: run.friendlyId,
snapshot: snapshot.friendlyId,
});
this.enterRunPhase(run, snapshot);
const metrics = [
{
name: "start",
event: "create_attempt",
timestamp: attemptStartedAt,
duration: attemptDuration,
},
].concat(
dequeuedAt
? [
{
name: "start",
event: "dequeue",
timestamp: dequeuedAt.getTime(),
duration: 0,
},
]
: []
);
try {
return await this.executeRun({ run, snapshot, execution, envVars, metrics });
} catch (error) {
logger.debug("Error while executing attempt", {
error,
});
logger.debug("Submitting attempt completion", {
runId: run.friendlyId,
snapshotId: snapshot.friendlyId,
updatedSnapshotId: this.snapshotFriendlyId,
});
const completion = {
id: execution.run.id,
ok: false,
retry: undefined,
error: TaskRunProcess.parseExecuteError(error),
} satisfies TaskRunFailedExecutionResult;
const completionResult = await this.httpClient.dev.completeRunAttempt(
run.friendlyId,
this.snapshotFriendlyId ?? snapshot.friendlyId,
{ completion }
);
if (!completionResult.success) {
logger.debug("Failed to submit completion after error", {
error: completionResult.error,
});
this.runFinished();
return;
}
logger.debug("Attempt completion submitted after error", completionResult.data.result);
try {
await this.handleCompletionResult(completion, completionResult.data.result, execution);
} catch (error) {
logger.debug("Failed to handle completion result after error", { error });
this.runFinished();
return;
}
}
}
private async executeRun({
run,
snapshot,
execution,
envVars,
metrics,
}: WorkloadRunAttemptStartResponseBody & {
metrics?: TaskRunExecutionMetrics;
}) {
if (!this.opts.worker.serverWorker) {
throw new Error(`No server worker for Dev ${run.friendlyId}`);
}
if (!this.opts.worker.manifest) {
throw new Error(`No worker manifest for Dev ${run.friendlyId}`);
}
this.snapshotPoller.start();
this.taskRunProcess = new TaskRunProcess({
workerManifest: this.opts.worker.manifest,
env: {
...sanitizeEnvVars(envVars ?? {}),
...sanitizeEnvVars(this.opts.worker.params.env),
TRIGGER_WORKER_MANIFEST_PATH: join(this.opts.worker.build.outputPath, "index.json"),
RUN_WORKER_SHOW_LOGS: this.opts.logLevel === "debug" ? "true" : "false",
TRIGGER_PROJECT_REF: execution.project.ref,
},
serverWorker: {
id: "unmanaged",
contentHash: this.opts.worker.build.contentHash,
version: this.opts.worker.serverWorker?.version,
engine: "V2",
},
machineResources: execution.machine,
}).initialize();
logger.debug("executing task run process", {
attemptNumber: execution.attempt.number,
runId: execution.run.id,
});
const completion = await this.taskRunProcess.execute({
payload: {
execution,
traceContext: execution.run.traceContext ?? {},
metrics,
},
messageId: run.friendlyId,
});
logger.debug("Completed run", completion);
try {
await this.taskRunProcess.cleanup(true);
this.taskRunProcess = undefined;
} catch (error) {
logger.debug("Failed to cleanup task run process, submitting completion anyway", {
error,
});
}
if (!this.runFriendlyId || !this.snapshotFriendlyId) {
logger.debug("executeRun: Missing run ID or snapshot ID after execution", {
runId: this.runFriendlyId,
snapshotId: this.snapshotFriendlyId,
});
this.runFinished();
return;
}
const completionResult = await this.httpClient.dev.completeRunAttempt(
this.runFriendlyId,
this.snapshotFriendlyId,
{
completion,
}
);
if (!completionResult.success) {
logger.debug("Failed to submit completion", {
error: completionResult.error,
});
this.runFinished();
return;
}
logger.debug("Attempt completion submitted", completionResult.data.result);
try {
await this.handleCompletionResult(completion, completionResult.data.result, execution);
} catch (error) {
logger.debug("Failed to handle completion result", { error });
this.runFinished();
return;
}
}
private async handleCompletionResult(
completion: TaskRunExecutionResult,
result: CompleteRunAttemptResult,
execution: TaskRunExecution
) {
logger.debug("[DevRunController] Handling completion result", { completion, result });
const { attemptStatus, snapshot: completionSnapshot, run } = result;
try {
this.updateRunPhase(run, completionSnapshot);
} catch (error) {
logger.debug("Failed to update run phase after completion", { error });
this.runFinished();
return;
}
if (attemptStatus === "RETRY_QUEUED") {
logger.debug("Retry queued");
this.runFinished();
return;
}
if (attemptStatus === "RETRY_IMMEDIATELY") {
if (completion.ok) {
throw new Error("Should retry but completion OK.");
}
if (!completion.retry) {
throw new Error("Should retry but missing retry params.");
}
await sleep(completion.retry.delay);
if (!this.snapshotFriendlyId) {
throw new Error("Missing snapshot ID after retry");
}
this.startAndExecuteRunAttempt({
runFriendlyId: run.friendlyId,
snapshotFriendlyId: this.snapshotFriendlyId,
}).finally(() => {});
return;
}
if (attemptStatus === "RUN_PENDING_CANCEL") {
logger.debug("Run pending cancel");
return;
}
eventBus.emit(
"runCompleted",
this.opts.worker,
execution,
completion,
completion.usage?.durationMs ?? 0
);
if (attemptStatus === "RUN_FINISHED") {
logger.debug("Run finished");
this.runFinished();
return;
}
assertExhaustive(attemptStatus);
}
private async runFinished() {
// Kill the run process
try {
await this.taskRunProcess?.kill("SIGKILL");
} catch (error) {
logger.debug("Failed to kill task run process", { error });
}
this.runHeartbeat.stop();
this.snapshotPoller.stop();
this.opts.onFinished();
}
private async cancelAttempt() {
logger.debug("Cancelling attempt", { runId: this.runFriendlyId });
await this.taskRunProcess?.cancel();
}
async start(dequeueMessage: DequeuedMessage) {
logger.debug("[DevRunController] Starting up");
await this.startAndExecuteRunAttempt({
runFriendlyId: dequeueMessage.run.friendlyId,
snapshotFriendlyId: dequeueMessage.snapshot.friendlyId,
dequeuedAt: dequeueMessage.dequeuedAt,
}).finally(async () => {});
}
async stop() {
logger.debug("[DevRunController] Shutting down");
process.off("SIGTERM", this.sigterm);
if (this.taskRunProcess && !this.taskRunProcess.isBeingKilled) {
try {
await this.taskRunProcess.cleanup(true);
} catch (error) {
logger.debug("Failed to cleanup task run process", { error });
}
}
this.runHeartbeat.stop();
this.snapshotPoller.stop();
}
async getLatestSnapshot() {
if (!this.runFriendlyId) {
return;
}
logger.debug("[DevRunController] Received notification, manually getting the latest snapshot.");
const response = await this.httpClient.dev.getRunExecutionData(this.runFriendlyId);
if (!response.success) {
logger.debug("Failed to get latest snapshot", { error: response.error });
return;
}
await this.handleSnapshotChange(response.data.execution);
}
resubscribeToRunNotifications() {
if (this.state.phase !== "RUN") {
return;
}
this.subscribeToRunNotifications(this.state);
}
}