{"record":{"id":"28ecbf11cb46b378","repo":"microsoft/typescript-go","slug":"failed-to-create-alloc-profile-file-w","errorCode":null,"errorMessage":"failed to create alloc profile file: %w","messagePattern":"failed to create alloc profile file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pprof/pprof.go","lineNumber":154,"sourceCode":"\truntime.GC()\n\tif err := pprof.Lookup(\"heap\").WriteTo(heapFile, 0); err != nil {\n\t\tos.Remove(heapProfilePath)\n\t\treturn \"\", fmt.Errorf(\"failed to write heap profile: %w\", err)\n\t}\n\n\treturn heapProfilePath, nil\n}\n\n// SaveAllocProfile saves an allocation profile to the specified directory.\nfunc SaveAllocProfile(profileDir string) (string, error) {\n\tif err := os.MkdirAll(profileDir, 0o755); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create profile directory: %w\", err)\n\t}\n\n\tallocProfilePath := filepath.Join(profileDir, fmt.Sprintf(\"%d-%d-allocprofile.pb.gz\", os.Getpid(), time.Now().UnixMilli()))\n\tallocFile, err := os.Create(allocProfilePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create alloc profile file: %w\", err)\n\t}\n\tdefer allocFile.Close()\n\n\tif err := pprof.Lookup(\"allocs\").WriteTo(allocFile, 0); err != nil {\n\t\tos.Remove(allocProfilePath)\n\t\treturn \"\", fmt.Errorf(\"failed to write alloc profile: %w\", err)\n\t}\n\n\treturn allocProfilePath, nil\n}\n\n// RunGC triggers garbage collection.\nfunc RunGC() {\n\truntime.GC()\n}\n","sourceCodeStart":136,"sourceCodeEnd":170,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/pprof/pprof.go#L136-L170","documentation":"SaveAllocProfile could not os.Create the alloc profile file in an existing directory. Mirrors the heap-file error: mkdir succeeded but creating the output file failed — permission mode on the directory, ENOSPC, filesystem policy, or I/O error. No profile is written.","triggerScenarios":"Directory writable for mkdir (already existed) but file creation denied; disk full; SELinux/AppArmor denial; NFS create refusal.","commonSituations":"Existing directories with restrictive modes (root-created dump dirs); quota-exceeded volumes; security-hardened hosts.","solutions":["Probe writability (create a temp file) in the target directory before the real call","Fix ownership/permissions or relocate profileDir","Free disk space"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if f, err := os.CreateTemp(profileDir, \"probe-*\"); err != nil {\n\treturn fmt.Errorf(\"alloc dump target unusable: %w\", err)\n} else {\n\tf.Close()\n\tos.Remove(f.Name())\n}","typeGuard":null,"tryCatchPattern":"if _, err := pprof.SaveAllocProfile(dir); err != nil {\n\tvar perr *fs.PathError\n\tif errors.As(err, &perr) && (perr.Err == syscall.EACCES || perr.Err == syscall.ENOSPC) {\n\t\treturn pprof.SaveAllocProfile(os.TempDir())\n\t}\n\treturn \"\", err\n}","preventionTips":["Probe writability before the incident, not during","Keep quota headroom for alloc profiles on long-lived servers","Fix directory ownership for the server user"],"tags":["pprof","allocations","disk-full","permissions"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}