mozilla/pdf.js · error · FormatError
Not tracking location of ${key}
Error message
Not tracking location of ${key} What it means
Thrown by CFFOffsetTracker.setEntryLocation when called for a key that was never registered via track(). setEntryLocation writes the final offset value into a placeholder slot that track() was supposed to reserve; calling it without a prior track means there is no slot to fill.
Source
Thrown at src/core/cff_parser.js:1461
return key in this.offsets;
}
track(key, location) {
if (key in this.offsets) {
throw new FormatError(`Already tracking location of ${key}`);
}
this.offsets[key] = location;
}
offset(value) {
for (const key in this.offsets) {
this.offsets[key] += value;
}
}
setEntryLocation(key, values, output) {
if (!(key in this.offsets)) {
throw new FormatError(`Not tracking location of ${key}`);
}
const data = output.data;
const dataOffset = this.offsets[key];
const size = 5;
for (let i = 0, ii = values.length; i < ii; ++i) {
const offset0 = i * size + dataOffset;
const offset1 = offset0 + 1;
const offset2 = offset0 + 2;
const offset3 = offset0 + 3;
const offset4 = offset0 + 4;
// It's easy to screw up offsets so perform this sanity check.
if (
data[offset0] !== 0x1d ||
data[offset1] !== 0 ||
data[offset2] !== 0 ||
data[offset3] !== 0 ||
data[offset4] !== 0
) {View on GitHub (pinned to 5903d58d58)
Solutions
- Verify the key passed to setEntryLocation was previously tracked via track() (or isTracking returns true).
- Report to pdf.js with the offending font — this indicates an internal compiler bug.
- Audit track/setEntryLocation call pairs to ensure matching key names.
Example fix
// before
tracker.setEntryLocation('Private', vals, output); // throws if never tracked
// after
if (tracker.isTracking('Private')) {
tracker.setEntryLocation('Private', vals, output);
} Defensive patterns
Strategy: validation
Validate before calling
// Only call setEntryLocation for keys previously tracked.
function safeSetEntryLocation(tracker, key, values, output) {
if (!tracker.isTracking(key)) {
throw new Error(`Refusing setEntryLocation: '${key}' not tracked`);
}
tracker.setEntryLocation(key, values, output);
} Type guard
function isTracked(tracker, key) {
return tracker.isTracking(key);
} Try / catch
try {
tracker.setEntryLocation(key, values, output);
} catch (e) {
// Key was never tracked; internal compiler state bug.
throw new Error(`setEntryLocation for untracked key '${key}'`);
} Prevention
- Ensure every setEntryLocation key was previously passed to track().
- Keep track/setEntryLocation key names in sync across refactors.
- Report unexpected occurrences to pdf.js with the offending font.
When it happens
Trigger: The CFF compiler calls setEntryLocation(key, values, output) for a key not in the tracker's offsets map. This is an internal invariant violation — setEntryLocation should only be called for offset names previously passed to track().
Common situations: A pdf.js internal bug where setEntryLocation references a name that compileDict never tracked; a fork that calls setEntryLocation directly; mismatched key names between track and setEntryLocation code paths after a refactor.
Related errors
- Already tracking location of ${key}
- writing to an offset that is not empty
- There must be a private dictionary.
- Unknown data type of ${type}
- Invalid dictionary name "${name}"
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/050e4b3a3d14ed66.
Report an issue: GitHub.