nektos/act · warning

CopyTarStream has been cancelled

Error message

CopyTarStream has been cancelled

What it means

Thrown by HostEnvironment.CopyTarStream while extracting a tar stream (e.g. restoring an action, artifact, or cache tarball onto the host filesystem). The loop checks ctx.Err() between tar entries and aborts as soon as the context is cancelled. It means the caller (job step, timeout, or Ctrl-C) cancelled the operation mid-extraction, not that the tar data itself is corrupt.

Source

Thrown at pkg/container/host_environment.go:83

	if err := os.RemoveAll(destPath); err != nil {
		return err
	}
	tr := tar.NewReader(tarStream)
	cp := &filecollector.CopyCollector{
		DstDir: destPath,
	}
	for {
		ti, err := tr.Next()
		if errors.Is(err, io.EOF) {
			return nil
		} else if err != nil {
			return err
		}
		if ti.FileInfo().IsDir() {
			continue
		}
		if ctx.Err() != nil {
			return fmt.Errorf("CopyTarStream has been cancelled")
		}
		if err := cp.WriteFile(ti.Name, ti.FileInfo(), ti.Linkname, tr); err != nil {
			return err
		}
	}
}

func (e *HostEnvironment) CopyDir(destPath string, srcPath string, useGitIgnore bool) common.Executor {
	return func(ctx context.Context) error {
		logger := common.Logger(ctx)
		srcPrefix := filepath.Dir(srcPath)
		if !strings.HasSuffix(srcPrefix, string(filepath.Separator)) {
			srcPrefix += string(filepath.Separator)
		}
		logger.Debugf("Stripping prefix:%s src:%s", srcPrefix, srcPath)
		var ignorer gitignore.Matcher
		if useGitIgnore {
			ps, err := gitignore.ReadPatterns(polyfill.New(osfs.New(srcPath)), nil)

View on GitHub (pinned to 4f41128141)

Solutions

  1. If the cancellation was unintentional, raise or remove the step/job timeout that cancelled the context.
  2. Re-run the job; partial extraction means the destination directory may need cleaning before retry.
  3. Check for the real upstream error — this message is a symptom; the root cause is whatever cancelled the context (network stall, slow tar source).
  4. If you call CopyTarStream from Go code, pass a context with a timeout sized to the tar size.

Example fix

# before (workflow)
steps:
  - uses: some/big-action@v1
    timeout-minutes: 1
# after
steps:
  - uses: some/big-action@v1
    timeout-minutes: 10
Defensive patterns

Strategy: try-catch

Try / catch

err := copyTarStream(ctx, r, cp)
if err != nil {
  if strings.Contains(err.Error(), 'CopyTarStream has been cancelled') || ctx.Err() != nil {
    // deliberate cancellation: clean partial output, do not retry blindly
    os.RemoveAll(dest)
    return ctx.Err()
  }
  return err
}

Prevention

When it happens

Trigger: CopyTarStream is invoked with a context that gets cancelled while entries remain: a step timeout fires during extraction, the user interrupts act (SIGINT), or a parent executor in the pipeline returns and cancels the run context.

Common situations: Large actions/caches being untarred when a per-job timeout expires; running act interactively and pressing Ctrl-C during 'clone' or 'extract' phases; Docker or artifact download being slow enough that an upstream deadline hits first.

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/270f091f97d58d4e. Report an issue: GitHub.