anomalyco/sst · error

failed to sync artifacts: %v

Error message

failed to sync artifacts: %v

What it means

PythonRuntime.Run first calls syncArtifactsIfNeeded to materialize the built artifact directory for the function; on failure it logs the functionID and underlying error, then returns "failed to sync artifacts: %v". This means the worker cannot start because the build output could not be synced/copied into place.

Source

Thrown at pkg/runtime/python/python.go:140

func (r *PythonRuntime) Match(runtime string) bool {
	return strings.HasPrefix(runtime, "python")
}

// ShouldRunEagerly returns false to enable lazy worker startup.
// Python lacks static import analysis, so any file change triggers ShouldRebuild()
// for ALL functions. Lazy startup avoids a startup storm of 50+ processes.
func (r *PythonRuntime) ShouldRunEagerly() bool {
	return false
}

func (r *PythonRuntime) Run(ctx context.Context, input *runtime.RunInput) (runtime.Worker, error) {
	isLegacyLayout, err := r.syncArtifactsIfNeeded(input)
	if err != nil {
		slog.Error("failed to sync artifacts",
			"functionID", input.FunctionID,
			"error", err)
		return nil, fmt.Errorf("failed to sync artifacts: %v", err)
	}

	// Copy lambda bridge to artifact directory if missing or outdated
	lambdaBridgePath := filepath.Join(input.Build.Out, "lambdaric_python_bridge.py")
	sourceBridgePath := filepath.Join(path.ResolvePlatformDir(input.CfgPath), "/dist/python-runtime/index.py")

	dstInfo, dstErr := os.Stat(lambdaBridgePath)
	srcInfo, srcErr := os.Stat(sourceBridgePath)
	if dstErr != nil || (srcErr == nil && srcInfo.ModTime().After(dstInfo.ModTime())) {
		if err := copyFile(sourceBridgePath, lambdaBridgePath); err != nil {
			return nil, fmt.Errorf("failed to copy lambda bridge: %v", err)
		}
	}

	projectRoot := path.ResolveRootDir(input.CfgPath)

	var handlerPath string
	var workingDir string

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Re-run the build (sst deploy / restart sst dev) so artifacts are regenerated, then retry.
  2. Inspect the logged 'error' field for the sync root cause (permissions, ENOSPC, missing dir).
  3. Free disk space or fix volume permissions if the OS error indicates ENOSPC/EACCES.
  4. Ensure the build output directory (.sst/... or Build.Out) exists and is writable before starting the runtime.

Example fix

// before
$ rm -rf .sst && sst dev  // stale state

// after
$ sst deploy   // rebuild artifacts first
$ sst dev
Defensive patterns

Strategy: try-catch

Validate before calling

// shell, before dev/deploy
test -d .sst && test -w .sst && df -h . | awk 'NR==2{exit ($4+0>1)?0:1}' || echo 'artifact dir missing/unwritable or disk full'

Try / catch

try { await deploy() } catch (e) {
  if (String(e).includes("failed to sync artifacts")) {
    // inspect logged root cause for functionID, then rebuild
    await rebuild();
  }
  throw e;
}

Prevention

When it happens

Trigger: syncArtifactsIfNeeded failed — typically the build output directory (input.Build.Out) is missing/empty (build didn't run or was cleaned), a disk/permission error prevented copying, or the legacy-layout detection hit an unreadable path.

Common situations: Running dev/deploy after manually deleting .sst or the build output; CI caching that restores an incomplete artifact dir; disk full; read-only volume mounts in containers; concurrent deploys clobbering the same out directory.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/cf0845ef7ec17965. Report an issue: GitHub.