mozilla/pdf.js · error · Error
app.thermometer is read-only
Error message
app.thermometer is read-only
What it means
app.thermometer is a lazily-created Proxy around a Thermometer progress helper that communicates via the send callback. It is viewer-internal state, so the setter throws. Reassigning would detach the progress UI wiring.
Source
Thrown at src/scripting_api/app.js:353
return this._runtimeHighlightColor;
}
set runtimeHighlightColor(val) {
if (Color._isValidColor(val)) {
this._runtimeHighlightColor = val;
/* TODO */
}
}
get thermometer() {
return (this._thermometer ??= new Proxy(
new Thermometer({ send: this._send }),
this._proxyHandler
));
}
set thermometer(_) {
throw new Error("app.thermometer is read-only");
}
get toolbar() {
return this._toolbar;
}
set toolbar(val) {
this._toolbar = val;
/* TODO */
}
get toolbarHorizontal() {
return this.toolbar;
}
set toolbarHorizontal(value) {
/* has been deprecated and it's now equivalent to toolbar */
this.toolbar = value;View on GitHub (pinned to 5903d58d58)
Solutions
- Use the returned Thermometer proxy's API (begin/update/end) instead of reassigning app.thermometer.
- For tests, mock at the underlying _externalCall/send layer.
- Read app.thermometer to obtain the current progress object.
Example fix
// before app.thermometer = myProgress; // after const t = app.thermometer; t.begin(); t.update(50);
Defensive patterns
Strategy: validation
Validate before calling
// app.thermometer is a viewer-managed progress proxy; use begin/update/end.
function runWithProgress(app, fn) {
const t = app.thermometer;
if (!t || typeof t.begin !== 'function') throw new Error('Thermometer unavailable');
t.begin(); try { return fn(t); } finally { t.end(); }
} Type guard
const isThermometer = (v) => v != null && typeof v === 'object' && typeof v.begin === 'function';
Try / catch
try { /* code that may assign app.thermometer */ }
catch (e) { if (!/thermometer is read-only/.test(e.message)) throw e; } Prevention
- Operate on the returned proxy; never replace app.thermometer.
- Mock progress at the _externalCall layer in tests.
- Always pair begin() with end() to keep the UI consistent.
When it happens
Trigger: Any assignment app.thermometer = ... in PDF JavaScript or API test code hits the throw at src/scripting_api/app.js:353.
Common situations: Long-running scripts trying to install a custom progress object; tests attempting to mock progress by overwriting the property.
Related errors
- app.fs is read-only
- app.activeDocs is read-only
- app.constants is read-only
- app.formsVersion is read-only
- app.fromPDFConverters is read-only
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/4e8011b17fea391d.
Report an issue: GitHub.