nodejs/node · error
dictionary [%s] is larger than maximum allowed: %d\n
Error message
dictionary [%s] is larger than maximum allowed: %d\n
What it means
The dictionary file size exceeds `kMaxDictionarySize`, which is `BROTLI_MAX_DISTANCE - BROTLI_MAX_BACKWARD_LIMIT(24)` (approximately 16 MiB minus 16 MiB = implementation-dependent; effectively the raw dictionary must fit within the encoder's maximum backward distance window). The message prints the offending path and the maximum allowed size in bytes.
Source
Thrown at deps/brotli/c/tools/brotli.c:909
if (context->dictionary_path == NULL) return BROTLI_TRUE;
f = fopen(context->dictionary_path, "rb");
if (f == NULL) {
fprintf(stderr, "failed to open dictionary file [%s]: %s\n",
PrintablePath(context->dictionary_path), strerror(errno));
return BROTLI_FALSE;
}
file_size_64 = FileSize(context->dictionary_path);
if (file_size_64 == -1) {
fprintf(stderr, "could not get size of dictionary file [%s]",
PrintablePath(context->dictionary_path));
fclose(f);
return BROTLI_FALSE;
}
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);View on GitHub (pinned to 1b2de5e052)
Solutions
- Trim or retrain the dictionary to be at most `kMaxDictionarySize` bytes.
- Verify you are pointing at the correct dictionary file, not a large data file.
- Check the value of `BROTLI_MAX_DISTANCE` and `BROTLI_MAX_BACKWARD_LIMIT(24)` in the build's headers to know the exact limit.
Defensive patterns
Strategy: validation
Validate before calling
#include <sys/stat.h>
#include <stdint.h>
#include <stdbool.h>
// BROTLI_MAX_DISTANCE is typically 0x3FFFFFFF (16 MiB window).
// The effective raw dict limit is implementation-dependent.
// Use a conservative 16 MiB ceiling for pre-validation:
#define SAFE_MAX_DICT (16 * 1024 * 1024)
bool dictionary_within_limit(const char *path) {
struct stat st;
if (stat(path, &st) != 0) return false;
return (int64_t)st.st_size <= SAFE_MAX_DICT;
} Prevention
- Check dictionary file size before passing it to brotli.
- Trim or retrain large dictionaries to stay under the limit.
- Print the exact limit from the error message and adjust your dictionary accordingly.
When it happens
Trigger: Supplying a dictionary file larger than the brotli encoder's maximum raw dictionary size. The limit is a compile-time constant derived from brotli's distance-coding parameters, not a user-configurable value.
Common situations: Using a large pre-trained dictionary for domain-specific compression (e.g. a web text corpus) that exceeds the limit; accidentally pointing `--dictionary` at a large data file instead of the intended small dictionary.
Related errors
- quality already set
- dictionary path already set\n
- failed to open dictionary file [%s]: %s\n
- could not get size of dictionary file [%s]
- could not read dictionary: out of memory\n
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/8ed31fc82c7ac83a.
Report an issue: GitHub.