{"record":{"id":"ade9db7df2cc59fc","repo":"microsoft/typescript-go","slug":"failed-to-write-alloc-profile-w","errorCode":null,"errorMessage":"failed to write alloc profile: %w","messagePattern":"failed to write alloc profile: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pprof/pprof.go","lineNumber":160,"sourceCode":"\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":142,"sourceCodeEnd":170,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/pprof/pprof.go#L142-L170","documentation":"SaveAllocProfile failed while pprof.Lookup(\"allocs\").WriteTo serialized the allocation profile to the opened file. The partial file is removed and the error wrapped. This is a mid-write I/O failure (disk full while writing a large alloc profile, EIO on failing storage) since the file was successfully created moments earlier.","triggerScenarios":"ENOSPC during serialization of a large allocation profile on a memory-heavy process; EIO on failing disks or flaky network mounts; writer interrupted by storage-layer errors.","commonSituations":"Profiling triggered during incidents when the disk is already near capacity; allocs profiles on long-running servers being gigabyte-scale; FUSE mounts with hard size limits.","solutions":["Guarantee free space proportional to allocation volume before dumping","Dump to local disk, then ship the artifact","Retry after resolving the storage condition"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if free := diskFree(profileDir); free < minFreeForAllocProfile {\n\treturn fmt.Errorf(\"need at least %d free for alloc profile\", minFreeForAllocProfile)\n}","typeGuard":null,"tryCatchPattern":"path, err := pprof.SaveAllocProfile(dir)\nif err != nil && strings.Contains(err.Error(), \"failed to write alloc profile\") {\n\tpath, err = pprof.SaveAllocProfile(os.TempDir()) // local retry, fresh target\n}\nif err != nil { return \"\", err }","preventionTips":["Write alloc profiles to local disk with ample free space","Retry once on transient storage errors, then surface the failure","Size reserved diagnostics space to the allocation volume of the process"],"tags":["pprof","allocations","io","disk-full"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}