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
This commit is contained in:
nicktrn
2025-09-16 16:17:04 +01:00
committed by GitHub
parent 501a383bcd
commit 885ae5e06f
5 changed files with 37 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"trigger.dev": patch
---
- Reduce restore times by 5s due to immediate polling
- Fix `s is not a function` and surface underlying error messages
@@ -514,7 +514,7 @@ export class ManagedRunController {
supervisorApiUrl: this.env.TRIGGER_SUPERVISOR_API_URL,
};
await this.currentExecution.processEnvOverrides("socket disconnected");
await this.currentExecution.processEnvOverrides("socket disconnected", true);
const newEnv = {
workerInstanceName: this.env.TRIGGER_WORKER_INSTANCE_NAME,
@@ -896,7 +896,10 @@ export class RunExecution {
/**
* Processes env overrides from the metadata service. Generally called when we're resuming from a suspended state.
*/
public async processEnvOverrides(reason?: string): Promise<{ overrides: Metadata } | null> {
public async processEnvOverrides(
reason?: string,
shouldPollForSnapshotChanges?: boolean
): Promise<{ overrides: Metadata } | null> {
if (!this.metadataClient) {
return null;
}
@@ -943,6 +946,12 @@ export class RunExecution {
this.httpClient.updateRunnerId(this.env.TRIGGER_RUNNER_ID);
}
// Poll for snapshot changes immediately
if (shouldPollForSnapshotChanges) {
this.sendDebugLog("[override] polling for snapshot changes", { reason });
this.fetchAndProcessSnapshotChanges("restore").catch(() => {});
}
return {
overrides,
};
+19 -1
View File
@@ -57,12 +57,30 @@ const wrappedClackSpinner = () => {
spinner.start(truncateMessage(currentMessage));
},
stop: (msg?: string, code?: number): void => {
isActive = false;
process.stdout.off("resize", handleResize);
if (!isActive) {
// Spinner was never started, just display the message
if (msg) {
log.message(msg);
}
return;
}
isActive = false;
spinner.stop(truncateMessage(msg ?? ""), code);
},
message: (msg?: string): void => {
currentMessage = msg ?? "";
if (!isActive) {
// Spinner was never started, just display the message
if (msg) {
log.message(msg);
}
return;
}
spinner.message(truncateMessage(currentMessage));
},
};
+1 -1
View File
@@ -24,7 +24,7 @@ if [[ -z "${GITHUB_TOKEN}" ]]; then
fi
# Use the first argument as version or 'v3-prerelease' if not available
version=${1:-'v3-prerelease'}
version=${1:-'v4-prerelease'}
# Ensure git stage is clear
if [[ $(git status --porcelain) ]]; then