From ecd6f1c82a086563211de9fc78864048b8e89964 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Tue, 3 Nov 2026 10:40:13 -0600 Subject: [PATCH 1/4] fix(workspace): allow slower detached worker startup --- cmd/workspace/up/detach.go | 3 ++- cmd/workspace/up/launch_handoff_test.go | 3 ++- .../docs/developing-in-workspaces/create-a-workspace.mdx | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/workspace/up/detach.go b/cmd/workspace/up/detach.go index f486c282fa..312947b4e4 100644 --- a/cmd/workspace/up/detach.go +++ b/cmd/workspace/up/detach.go @@ -60,6 +60,7 @@ func (cmd *UpCmd) runDetached(args []string, cfg *config.Config) error { } const detachedLookupTimeout = 30 * time.Second +const detachedLaunchTimeout = 30 * time.Second func (cmd *UpCmd) checkDetachedPresentation(cfg *config.Config, workspaceID string) error { ctx, cancel := context.WithTimeout(context.Background(), detachedLookupTimeout) @@ -136,7 +137,7 @@ func launchDetached(t *task.Task, invocationEnv []string) error { if err := t.PublishProcess(ref); err != nil { return err } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), detachedLaunchTimeout) defer cancel() return t.CommitLaunch(ctx) }, diff --git a/cmd/workspace/up/launch_handoff_test.go b/cmd/workspace/up/launch_handoff_test.go index bb1b3e455d..5a8274a6d7 100644 --- a/cmd/workspace/up/launch_handoff_test.go +++ b/cmd/workspace/up/launch_handoff_test.go @@ -23,7 +23,7 @@ func TestDetachedWorkerCommitsBeforeWorkspaceWork(t *testing.T) { if err := tk.PublishProcess(ref); err != nil { return err } - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), detachedLaunchTimeout) defer cancel() return tk.CommitLaunch(ctx) }, @@ -52,6 +52,7 @@ func TestDetachedWorkerHandoffHelper(t *testing.T) { if id == "" { return } + time.Sleep(6 * time.Second) cmd := &UpCmd{taskID: id} tk, err := cmd.openTask() require.NoError(t, err) diff --git a/sites/docs-devsy-sh/content/docs/developing-in-workspaces/create-a-workspace.mdx b/sites/docs-devsy-sh/content/docs/developing-in-workspaces/create-a-workspace.mdx index 38d75a3fe8..6359429e52 100644 --- a/sites/docs-devsy-sh/content/docs/developing-in-workspaces/create-a-workspace.mdx +++ b/sites/docs-devsy-sh/content/docs/developing-in-workspaces/create-a-workspace.mdx @@ -104,6 +104,8 @@ devsy workspace logs WORKSPACE_NAME --source setup --run RUN_ID --result-format= The run ID appears in the result of `devsy workspace up` and in the output of a detached creation task. Use `--list` to find IDs for earlier runs. +For a detached creation, Devsy waits up to 30 seconds for the background worker to register. Workspace setup continues after the command returns. If the worker cannot register within that time, the launch fails and Devsy cleans it up. + - Hooks that run after `waitFor` (default `updateContentCommand`) can finish after `up` returns. Their output joins the same run. Add `--follow` to watch them. - A hook that an earlier attempt already marked is skipped with the reason `already_attempted`. This does not mean the earlier attempt succeeded. Check that run. - `postAttachCommand` runs on every attach. Each run is recorded separately. From fba3047a97b8650be7c31cf4408e1298257c0da1 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Tue, 3 Nov 2026 11:14:01 -0600 Subject: [PATCH 2/4] style(workspace): group detached launch timeouts --- cmd/workspace/up/detach.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/workspace/up/detach.go b/cmd/workspace/up/detach.go index 312947b4e4..7fa1d59beb 100644 --- a/cmd/workspace/up/detach.go +++ b/cmd/workspace/up/detach.go @@ -59,8 +59,10 @@ func (cmd *UpCmd) runDetached(args []string, cfg *config.Config) error { return cmd.renderDetachedTask(t, runID) } -const detachedLookupTimeout = 30 * time.Second -const detachedLaunchTimeout = 30 * time.Second +const ( + detachedLookupTimeout = 30 * time.Second + detachedLaunchTimeout = 30 * time.Second +) func (cmd *UpCmd) checkDetachedPresentation(cfg *config.Config, workspaceID string) error { ctx, cancel := context.WithTimeout(context.Background(), detachedLookupTimeout) From d8e602189f66765477c0f65769ca0def3d85c671 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Tue, 3 Nov 2026 11:16:05 -0600 Subject: [PATCH 3/4] test(workspace): exercise production detached handoff --- cmd/workspace/up/detach.go | 16 ++++++++++------ cmd/workspace/up/launch_handoff_test.go | 8 +------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cmd/workspace/up/detach.go b/cmd/workspace/up/detach.go index 7fa1d59beb..bf051e7ff4 100644 --- a/cmd/workspace/up/detach.go +++ b/cmd/workspace/up/detach.go @@ -136,12 +136,7 @@ func launchDetached(t *task.Task, invocationEnv []string) error { AtomicOwnership: true, OnPrepared: t.PrepareProcessOwnership, OnStarted: func(ref command.ProcessRef) error { - if err := t.PublishProcess(ref); err != nil { - return err - } - ctx, cancel := context.WithTimeout(context.Background(), detachedLaunchTimeout) - defer cancel() - return t.CommitLaunch(ctx) + return commitDetachedLaunch(t, ref) }, }, func() (*exec.Cmd, error) { return &exec.Cmd{ @@ -153,6 +148,15 @@ func launchDetached(t *task.Task, invocationEnv []string) error { }) } +func commitDetachedLaunch(t *task.Task, ref command.ProcessRef) error { + if err := t.PublishProcess(ref); err != nil { + return err + } + ctx, cancel := context.WithTimeout(context.Background(), detachedLaunchTimeout) + defer cancel() + return t.CommitLaunch(ctx) +} + // detachedArgs strips --detach so it isn't duplicated alongside --task-id. func detachedArgs(args []string) []string { detachFlag := names.Flag(names.Detach) diff --git a/cmd/workspace/up/launch_handoff_test.go b/cmd/workspace/up/launch_handoff_test.go index 5a8274a6d7..2bfdf0a66d 100644 --- a/cmd/workspace/up/launch_handoff_test.go +++ b/cmd/workspace/up/launch_handoff_test.go @@ -1,7 +1,6 @@ package up import ( - "context" "os" "os/exec" "testing" @@ -20,12 +19,7 @@ func TestDetachedWorkerCommitsBeforeWorkspaceWork(t *testing.T) { Name: task.WorkerProcessName(tk.ID()), Lease: tk.LaunchLease(), AtomicOwnership: true, OnPrepared: tk.PrepareProcessOwnership, OnStarted: func(ref command.ProcessRef) error { - if err := tk.PublishProcess(ref); err != nil { - return err - } - ctx, cancel := context.WithTimeout(context.Background(), detachedLaunchTimeout) - defer cancel() - return tk.CommitLaunch(ctx) + return commitDetachedLaunch(tk, ref) }, }, func() (*exec.Cmd, error) { child := exec.Command( From b59c81588ef8107420385668bef2d31ba5b43a19 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Tue, 3 Nov 2026 13:09:07 -0600 Subject: [PATCH 4/4] test(workspace): use local fixture for environment spec --- e2e/README.md | 2 ++ e2e/tests/up/up.go | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e/README.md b/e2e/README.md index 0ba37f9069..381bf12533 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -30,6 +30,8 @@ mise run cli:test:e2e:suite up-docker-compose mise run cli:test:e2e:focus "pattern" ``` +The `with env vars` workspace spec uses a local Docker fixture. Its repeated `up` calls test environment changes without waiting for remote repository inspection. + `cli:test:e2e:act:focus` runs a focused pattern through [act](https://github.com/nektos/act). The Docker lifecycle regression covers values with `=` from `--workspace-env` and diff --git a/e2e/tests/up/up.go b/e2e/tests/up/up.go index 0e3c68c9e1..161109a0f3 100644 --- a/e2e/tests/up/up.go +++ b/e2e/tests/up/up.go @@ -43,11 +43,10 @@ var _ = ginkgo.Describe("testing up command", ginkgo.Label("up-workspaces"), fun f, err := framework.SetupDockerProvider(filepath.Join(initialDir, "bin"), dockerValue) framework.ExpectNoError(err) - name := "vscode-remote-try-python" + name := framework.CopyTestdata("tests/up/testdata/docker", initialDir) ginkgo.DeferCleanup(f.DevsyWorkspaceDelete, name) - // Wait for devsy workspace to come online (deadline: 30s) - err = f.DevsyUp(ctx, "https://github.com/microsoft/vscode-remote-try-python.git") + err = f.DevsyUp(ctx, name) framework.ExpectNoError(err) // check env var