{"record":{"id":"609a62a6cc16c50e","repo":"multica-ai/multica","slug":"close-temp-for-s-w","errorCode":null,"errorMessage":"close temp for %s: %w","messagePattern":"close temp for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/hermes_home.go","lineNumber":930,"sourceCode":"// file and a prior file's looser permissions are replaced.\nfunc writeFileAtomic(dst string, data []byte, perm os.FileMode) error {\n\tdir := filepath.Dir(dst)\n\ttmp, err := os.CreateTemp(dir, \".hermes-tmp-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp for %s: %w\", dst, err)\n\t}\n\ttmpName := tmp.Name()\n\tdefer os.Remove(tmpName) // no-op once renamed\n\tif _, err := tmp.Write(data); err != nil {\n\t\ttmp.Close()\n\t\treturn fmt.Errorf(\"write temp for %s: %w\", dst, err)\n\t}\n\tif err := tmp.Chmod(perm); err != nil {\n\t\ttmp.Close()\n\t\treturn fmt.Errorf(\"chmod temp for %s: %w\", dst, err)\n\t}\n\tif err := tmp.Close(); err != nil {\n\t\treturn fmt.Errorf(\"close temp for %s: %w\", dst, err)\n\t}\n\tif err := os.Rename(tmpName, dst); err != nil {\n\t\treturn fmt.Errorf(\"rename temp to %s: %w\", dst, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":912,"sourceCodeEnd":937,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/hermes_home.go#L912-L937","documentation":"writeFileAtomic could not Close the temp file after write+chmod. On local disks Close rarely fails; on network filesystems it is where delayed write errors (ENOSPC, EIO, commit failures) surface, so the helper treats a failed close as a failed write and never renames a suspect file into place.","triggerScenarios":"NFS async-write commit failure at close; ENOSPC reported only at flush; SMB disconnect mid-operation; filesystem gone read-only between write and close.","commonSituations":"Env RootDir on NFS/SMB shares under load or after a network blip; thinly-provisioned volume running out of space at commit time.","solutions":["Check storage health and free space; for NFS look for 'commit failed' / EIO in dmesg.","Stabilize or remount the network share, then retry the task.","Prefer local volumes for env RootDir to avoid close-time write semantics entirely.","If it recurs on one file, inspect that path for a corrupted directory entry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := writeFileAtomic(dst, data, perm)\nif err != nil && strings.Contains(err.Error(), \"close temp\") {\n\t// network FS may report delayed write errors at close — single retry after a beat\n\ttime.Sleep(250 * time.Millisecond)\n\terr = writeFileAtomic(dst, data, perm)\n}\nreturn err","preventionTips":["Monitor NFS commit failures (nfsstat, dmesg) when env roots live on NFS.","Treat close-time errors as write failures — never consume a file whose temp close failed."],"tags":["filesystem","io","network-storage","atomic-write","hermes"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}