wavetermdev/waveterm · warning
cancelled while waiting for app port: %w
Error message
cancelled while waiting for app port: %w
What it means
While waiting for the builder app's port, runBuilderApp also watches the caller's context. If the context is cancelled (user cancelled the build, block closed, app shutdown), the subprocess is killed and this error wraps ctx.Err() (context.Canceled or context.DeadlineExceeded).
Source
Thrown at pkg/buildercontroller/buildercontroller.go:411
}
}()
timeout := time.NewTimer(5 * time.Second)
defer timeout.Stop()
select {
case port := <-portChan:
process.Port = port
return process, nil
case err := <-errChan:
cmd.Process.Kill()
return nil, err
case <-timeout.C:
cmd.Process.Kill()
return nil, fmt.Errorf("timeout waiting for port")
case <-ctx.Done():
cmd.Process.Kill()
return nil, fmt.Errorf("cancelled while waiting for app port: %w", ctx.Err())
}
}
func (bc *BuilderController) handleBuildError(err error, resultCh chan<- *BuildResult) {
bc.lock.Lock()
defer bc.lock.Unlock()
bc.setStatus_nolock(BuilderStatus_Error, 0, 1, err.Error())
if resultCh != nil {
buildOutput := ""
if bc.outputBuffer != nil {
lines := bc.outputBuffer.GetLines()
buildOutput = strings.Join(lines, "\n")
}
select {
case resultCh <- &BuildResult{
Success: false,
ErrorMessage: err.Error(),View on GitHub (pinned to a4447c1563)
Solutions
- Confirm the cancellation was intentional (block closed / user cancel); if so, no action needed
- If unintended, check ancestor context deadlines that expire during startup
- Retry the build with a fresh context if the cancellation was accidental
Defensive patterns
Strategy: try-catch
Try / catch
process, err := bc.runBuilderApp(ctx, ...)
if err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return nil // expected on cancel/shutdown; clean up quietly
}
return err
} Prevention
- Pass a context whose lifetime covers the full build+startup window
- Avoid ancestor contexts with deadlines shorter than the 5s port wait
- Treat cancellation as normal flow when closing blocks or shutting down
- Use errors.Is on the wrapped ctx.Err() to distinguish cancel vs deadline
When it happens
Trigger: ctx.Done() fires during the 5-second port wait — caller cancellation, block teardown, or a context deadline set by an ancestor expiring.
Common situations: User closes the terminal block or cancels the run while the builder app is starting; Wave shutdown cancels in-flight builds; upstream deadline shorter than the 5s port wait.
Related errors
- failed to create stdout pipe: %w
- failed to create stderr pipe: %w
- failed to create stdin pipe: %w
- failed to start process: %w
- process died before emitting port
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/726e916866fcef04.
Report an issue: GitHub.