mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-19 00:03:19 +00:00
fix: poll a background fork by the id of its own attempt
create_fork?background=true answers with a creation id, and the status route reads that attempt only, for the user who started it. A retry that reuses the fork id is a new attempt, so a poller never reads another attempt's outcome. The AI-session fork no longer adopts a creation in flight, which it could not tell apart from someone else's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a6e2f7abf2
commit
4cf481fa34
@@ -13,6 +13,7 @@ import {
|
||||
renameCurrentGitBranch,
|
||||
} from "../../utils/git.ts";
|
||||
import process from "node:process";
|
||||
import { apiErrorMessage } from "../../utils/utils.ts";
|
||||
import { WM_FORK_PREFIX } from "../../core/constants.ts";
|
||||
import { tryResolveBranchWorkspace } from "../../core/context.ts";
|
||||
import {
|
||||
@@ -22,8 +23,8 @@ import {
|
||||
readConfigFile,
|
||||
} from "../../core/conf.ts";
|
||||
|
||||
/** Wait for the creation of a fork started in the background by this user. */
|
||||
async function waitForForkCreation(parentWorkspace: string, forkId: string) {
|
||||
/** Wait for a fork creation started in the background, by the id its request answered with. */
|
||||
async function waitForForkCreation(parentWorkspace: string, creationId: string) {
|
||||
let failingSince: number | undefined;
|
||||
let lastStep: string | undefined;
|
||||
while (true) {
|
||||
@@ -33,7 +34,7 @@ async function waitForForkCreation(parentWorkspace: string, forkId: string) {
|
||||
try {
|
||||
result = await wmill.getForkCreationStatus({
|
||||
workspace: parentWorkspace,
|
||||
forkWorkspaceId: forkId,
|
||||
creationId,
|
||||
});
|
||||
failingSince = undefined;
|
||||
} catch (e) {
|
||||
@@ -420,13 +421,15 @@ async function createWorkspaceFork(
|
||||
});
|
||||
// A server without background forks ignores the flag and answers once the fork is created.
|
||||
if (!response.startsWith("Created forked workspace")) {
|
||||
await waitForForkCreation(workspace.workspaceId, trueWorkspaceId);
|
||||
await waitForForkCreation(workspace.workspaceId, response);
|
||||
}
|
||||
|
||||
log.info(colors.green(`✅ Created forked workspace ${trueWorkspaceId}`));
|
||||
} catch (error) {
|
||||
log.error(
|
||||
colors.red(`Failed to create forked workspace: ${(error as Error).message}`),
|
||||
colors.red(
|
||||
`Failed to create forked workspace: ${apiErrorMessage(error) ?? (error as Error).message}`,
|
||||
),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user