juicedata/juicefs · error

timeout after %s: %w

Error message

timeout after %s: %w

What it means

WithTimeout runs fn in a goroutine and returns ErrFuncTimeout wrapped as 'timeout after %s: %w' when the operation does not finish within the given duration. The wrapped ctx.Err() path is separate; this error specifically means the timer fired first.

Source

Thrown at pkg/utils/utils.go:125

	return ips, nil
}

func WithTimeout(pCtx context.Context, f func(context.Context) error, timeout time.Duration) error {
	done := make(chan error, 1)
	t := time.NewTimer(timeout)
	ctx, cancel := context.WithCancel(pCtx)
	defer cancel()
	defer t.Stop()
	go func() {
		done <- f(ctx)
	}()
	select {
	case <-ctx.Done():
		return ctx.Err()
	case err := <-done:
		return err
	case <-t.C:
		return fmt.Errorf("timeout after %s: %w", timeout, ErrFuncTimeout)
	}
}

func RemovePassword(uri string) string {
	p := strings.LastIndex(uri, "@")
	if p < 0 {
		return uri
	}
	sp := strings.Index(uri, "://") + 3
	if sp == 2 {
		sp = 0
	}
	cp := strings.Index(uri[sp:], ":")
	if cp < 0 || sp+cp > p {
		return uri
	}
	return uri[:sp+cp] + ":****" + uri[p:]
}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Increase the relevant timeout for the operation
  2. Investigate why the underlying operation hangs (logs, strace, mount status)
  3. Retry once the system is responsive
  4. For mount failures, check FUSE device availability and metadata engine connectivity

Example fix

// before
err := utils.WithTimeout(fn, 5*time.Second)
// after
err := utils.WithTimeout(fn, 60*time.Second)
Defensive patterns

Strategy: try-catch

Try / catch

if err := utils.WithTimeout(fn, timeout); err != nil {
  if errors.Is(err, utils.ErrFuncTimeout) { /* retry or raise timeout */ }
  return err
}

Prevention

When it happens

Trigger: Any wrapped operation (copyFile, getPprofPort, collectSpecialFile, debug, getCmdMount, mount) exceeding its timeout — slow disk copy, hung subprocess, stalled mount, profile collection on a busy process.

Common situations: Large file copies during warm-up/upgrade; `juicefs debug` collecting info from a hung mount; slow or wedged FUSE mount at startup.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/1b272c4f3793cf09. Report an issue: GitHub.