diff --git a/util/headerreader/blob_client.go b/util/headerreader/blob_client.go index 56ea6f7414..2a99207e8c 100644 --- a/util/headerreader/blob_client.go +++ b/util/headerreader/blob_client.go @@ -374,6 +374,7 @@ func saveBlobDataToDisk(rawData json.RawMessage, slot uint64, blobDirectory stri return fmt.Errorf("could not create file to store fetched blobs") } full := fullResult[json.RawMessage]{Data: rawData} + defer file.Close() fullbytes, err := json.Marshal(full) if err != nil { return fmt.Errorf("unable to marshal data into bytes while attempting to store fetched blobs") @@ -381,7 +382,6 @@ func saveBlobDataToDisk(rawData json.RawMessage, slot uint64, blobDirectory stri if _, err := file.Write(fullbytes); err != nil { return fmt.Errorf("failed to write blob data to disk") } - file.Close() return nil }