{"record":{"id":"dbc9ece1decc5735","repo":"kovidgoyal/kitty","slug":"failed-to-create-a-temp-file-for-image-data-transm","errorCode":null,"errorMessage":"Failed to create a temp file for image data transmission: %w","messagePattern":"Failed to create a temp file for image data transmission: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/icat/transmit.go","lineNumber":137,"sourceCode":"\terr = gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(mmap.Name()))\n\treturn\n}\n\nfunc transmit_file(imgd *image_data, frame_num int, frame *image_frame) (err error) {\n\tis_temp := false\n\tfname := \"\"\n\tvar data_size int\n\tif frame.in_memory_bytes == nil {\n\t\tfname, err = filepath.Abs(frame.filename)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to convert image data output file: %s to absolute path with error: %w\", frame.filename, err)\n\t\t}\n\t\tframe.filename = \"\" // so it isn't deleted in cleanup\n\t} else {\n\t\tis_temp = true\n\t\tf, err := images.CreateTempInRAM()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to create a temp file for image data transmission: %w\", err)\n\t\t}\n\t\tdata_size = len(frame.in_memory_bytes)\n\t\t_, err = bytes.NewBuffer(frame.in_memory_bytes).WriteTo(f)\n\t\tf.Close()\n\t\tif err != nil {\n\t\t\tos.Remove(f.Name())\n\t\t\treturn fmt.Errorf(\"Failed to write image data to temp file for transmission: %w\", err)\n\t\t}\n\t\tfname = f.Name()\n\t}\n\tgc := gc_for_image(imgd, frame_num, frame)\n\tgc.SetTransmission(utils.IfElse(is_temp, graphics.GRT_transmission_tempfile, graphics.GRT_transmission_file))\n\tif data_size > 0 {\n\t\tgc.SetDataSize(uint64(data_size))\n\t}\n\treturn gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(fname))\n}\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/icat/transmit.go#L119-L155","documentation":"For in-memory frames sent by file transmission, icat writes the bytes to a RAM-backed temp file (images.CreateTempInRAM); creating that temp file failed.","triggerScenarios":"CreateTempInRAM failing — tmpfs (e.g. /dev/shm or TMPDIR pointing at tmpfs) full or unwritable, or too many temp files.","commonSituations":"Small /dev/shm in containers with large images; TMPDIR set to a full/unwritable location; file-descriptor exhaustion.","solutions":["Free space in the tmpfs/TMPDIR used for temp files or enlarge it","Set TMPDIR to a location with adequate space","Reduce image sizes; close other processes hogging fds/space"],"exampleFix":"# before\ndocker run ... kitten icat big.png\n# after\ndocker run -e TMPDIR=/var/tmp ... kitten icat big.png","handlingStrategy":"fallback","validationCode":"var s syscall.Statfs_t\nsyscall.Statfs(os.TempDir(), &s)\nif s.Bavail*uint64(s.Bsize) < uint64(imgSize) { /* free space or set bigger TMPDIR */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"temp file\") { /* free tmpfs or point TMPDIR elsewhere and retry */ }","preventionTips":["Keep TMPDIR/tmpfs with free space for large images","Set TMPDIR to a roomy local directory in containers"],"tags":["kitty","icat","tempfile","tmpfs"],"backgroundTag":"temp-file-creation-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}