nodejs/node · error
failed to read dictionary [%s]: %s\n
Error message
failed to read dictionary [%s]: %s\n
What it means
`fread` on the dictionary file returned fewer bytes than expected (`bytes_read != context->dictionary_size`). The file was opened and sized successfully, but the actual read was short. The buffer is freed and the dictionary path + errno are reported.
Source
Thrown at deps/brotli/c/tools/brotli.c:925
if (file_size_64 > kMaxDictionarySize) {
fprintf(stderr, "dictionary [%s] is larger than maximum allowed: %d\n",
PrintablePath(context->dictionary_path), kMaxDictionarySize);
fclose(f);
return BROTLI_FALSE;
}
context->dictionary_size = (size_t)file_size_64;
buffer = (uint8_t*)malloc(context->dictionary_size);
if (!buffer) {
fprintf(stderr, "could not read dictionary: out of memory\n");
fclose(f);
return BROTLI_FALSE;
}
bytes_read = fread(buffer, sizeof(uint8_t), context->dictionary_size, f);
if (bytes_read != context->dictionary_size) {
free(buffer);
fprintf(stderr, "failed to read dictionary [%s]: %s\n",
PrintablePath(context->dictionary_path), strerror(errno));
fclose(f);
return BROTLI_FALSE;
}
fclose(f);
context->dictionary = buffer;
if (command == COMMAND_COMPRESS) {
context->prepared_dictionary = BrotliEncoderPrepareDictionary(
BROTLI_SHARED_DICTIONARY_RAW, context->dictionary_size,
context->dictionary, BROTLI_MAX_QUALITY, NULL, NULL, NULL);
if (context->prepared_dictionary == NULL) {
fprintf(stderr, "failed to prepare dictionary [%s]\n",
PrintablePath(context->dictionary_path));
return BROTLI_FALSE;
}
}
return BROTLI_TRUE;
}View on GitHub (pinned to 1b2de5e052)
Solutions
- Re-read the dictionary file from stable storage.
- Ensure no other process is modifying the dictionary file during compression.
- Copy the dictionary to a local filesystem (e.g. /tmp) to avoid network I/O issues.
- Verify file integrity with `sha256sum` before and after.
Defensive patterns
Strategy: retry
Validate before calling
#include <sys/stat.h>
#include <stdbool.h>
bool dictionary_stable(const char *path, time_t *prev_mtime) {
struct stat st;
if (stat(path, &st) != 0) return false;
if (*prev_mtime != 0 && st.st_mtime != *prev_mtime) return false;
*prev_mtime = st.st_mtime;
return true;
} Prevention
- Copy the dictionary to a local, read-only location before use.
- Ensure no other process writes to the dictionary file during compression.
- Verify file integrity with a checksum before and after each run.
When it happens
Trigger: An I/O error occurred during the read (disk fault, NFS timeout); the file was truncated between `FileSize` and `fread` (race with another process writing/shrinking it); a read interruption on a network-mounted filesystem.
Common situations: Dictionary file being concurrently modified; storage media degradation; NFS mount with intermittent connectivity; file on a FUSE filesystem that returns short reads.
Related errors
- failed to open dictionary file [%s]: %s\n
- could not get size of dictionary file [%s]
- failed to read input [%s]: %s\n
- dictionary path already set\n
- failed to open input file [%s]: %s\n
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/2bf8ea6143f22c68.
Report an issue: GitHub.