Tencent/WeKnora · error

E2B timeout must be at least one second

Error message

E2B timeout must be at least one second

What it means

E2B exposes sandbox timeouts only as whole-second positive TTLs. e2bTimeoutSeconds rejects durations greater than zero but under one second, since they cannot be represented (E2B has no sub-second or zero TTL), so the lifecycle coordinator can fall back to a different timeout policy rather than silently truncating.

Source

Thrown at internal/sandbox/e2b_remote_client.go:1084

		// image orphan cleanup. Fail fast instead of hanging until cancel.
		if _, dup := seen[page.NextToken]; dup {
			return nil, e2bInvalidRequest("ListSnapshots",
				"provider returned a repeated pagination token", nil)
		}
		seen[page.NextToken] = struct{}{}
		token = page.NextToken
	}
}

// --- helpers -----------------------------------------------------------------

// e2bTimeoutSeconds maps the neutral RemoteTimeoutPolicy onto E2B's integer
// timeout. E2B only supports a positive TTL; "never" is rejected as
// unsupported so the lifecycle coordinator can pick a different policy.
func e2bTimeoutSeconds(policy RemoteTimeoutPolicy, fallback time.Duration) (int, error) {
	toSeconds := func(value time.Duration) (int, error) {
		if value > 0 && value < time.Second {
			return 0, errors.New("E2B timeout must be at least one second")
		}
		seconds := value / time.Second
		if value%time.Second != 0 {
			seconds++
		}
		return int(seconds), nil
	}

	switch policy.Mode {
	case "", RemoteTimeoutServerDefault:
		if fallback <= 0 {
			return 0, nil
		}
		return toSeconds(fallback)
	case RemoteTimeoutExplicit:
		if policy.Value < 0 {
			return 0, errors.New("E2B backend does not support NeverTimeout")
		}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Raise the configured timeout to at least 1 * time.Second
  2. Clamp sub-second durations to 1 second before passing them to the E2B client
  3. Use a different backend (e.g. Docker) if sub-second sandbox TTLs are genuinely required

Example fix

// before
timeout := 500 * time.Millisecond
// after
timeout := 500 * time.Millisecond
if timeout < time.Second {
    timeout = time.Second
}
Defensive patterns

Strategy: validation

Validate before calling

func clampE2BTimeout(d time.Duration) time.Duration {
    if d > 0 && d < time.Second {
        return time.Second
    }
    return d
}
// apply before mapping policy: policy.Value = clampE2BTimeout(policy.Value)

Prevention

When it happens

Trigger: Any operation that maps a RemoteTimeoutPolicy (Create, Connect, Get, Delete, CreateSnapshot, or the anonymous fallback mapper) where the effective duration is e.g. 500ms — either an explicit policy value < 1s or a fallback duration < 1s.

Common situations: Config sets very aggressive timeout values for fast tests; a caller converts a millisecond-based setting into time.Duration without enforcing a 1s floor; a sub-second fallback duration is passed to e2bTimeoutSeconds.

Understand the failure class

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/0ba7f976f90c37b0. Report an issue: GitHub.