Skip to content

Commit 885ae5e

Browse files
authored
fix(runner): immediate poll to decrease restore time (#2516)
* fix(runner): immediate poll to decrease restore time * chore: bump default prerelease tag * fix(cli): s is not a function * add changeset
1 parent 501a383 commit 885ae5e

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

.changeset/sharp-cheetahs-end.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
- Reduce restore times by 5s due to immediate polling
6+
- Fix `s is not a function` and surface underlying error messages

packages/cli-v3/src/entryPoints/managed/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export class ManagedRunController {
514514
supervisorApiUrl: this.env.TRIGGER_SUPERVISOR_API_URL,
515515
};
516516

517-
await this.currentExecution.processEnvOverrides("socket disconnected");
517+
await this.currentExecution.processEnvOverrides("socket disconnected", true);
518518

519519
const newEnv = {
520520
workerInstanceName: this.env.TRIGGER_WORKER_INSTANCE_NAME,

packages/cli-v3/src/entryPoints/managed/execution.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,10 @@ export class RunExecution {
896896
/**
897897
* Processes env overrides from the metadata service. Generally called when we're resuming from a suspended state.
898898
*/
899-
public async processEnvOverrides(reason?: string): Promise<{ overrides: Metadata } | null> {
899+
public async processEnvOverrides(
900+
reason?: string,
901+
shouldPollForSnapshotChanges?: boolean
902+
): Promise<{ overrides: Metadata } | null> {
900903
if (!this.metadataClient) {
901904
return null;
902905
}
@@ -943,6 +946,12 @@ export class RunExecution {
943946
this.httpClient.updateRunnerId(this.env.TRIGGER_RUNNER_ID);
944947
}
945948

949+
// Poll for snapshot changes immediately
950+
if (shouldPollForSnapshotChanges) {
951+
this.sendDebugLog("[override] polling for snapshot changes", { reason });
952+
this.fetchAndProcessSnapshotChanges("restore").catch(() => {});
953+
}
954+
946955
return {
947956
overrides,
948957
};

packages/cli-v3/src/utilities/windows.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,30 @@ const wrappedClackSpinner = () => {
5757
spinner.start(truncateMessage(currentMessage));
5858
},
5959
stop: (msg?: string, code?: number): void => {
60-
isActive = false;
6160
process.stdout.off("resize", handleResize);
61+
62+
if (!isActive) {
63+
// Spinner was never started, just display the message
64+
if (msg) {
65+
log.message(msg);
66+
}
67+
return;
68+
}
69+
70+
isActive = false;
6271
spinner.stop(truncateMessage(msg ?? ""), code);
6372
},
6473
message: (msg?: string): void => {
6574
currentMessage = msg ?? "";
75+
76+
if (!isActive) {
77+
// Spinner was never started, just display the message
78+
if (msg) {
79+
log.message(msg);
80+
}
81+
return;
82+
}
83+
6684
spinner.message(truncateMessage(currentMessage));
6785
},
6886
};

scripts/publish-prerelease.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [[ -z "${GITHUB_TOKEN}" ]]; then
2424
fi
2525

2626
# Use the first argument as version or 'v3-prerelease' if not available
27-
version=${1:-'v3-prerelease'}
27+
version=${1:-'v4-prerelease'}
2828

2929
# Ensure git stage is clear
3030
if [[ $(git status --porcelain) ]]; then

0 commit comments

Comments
 (0)