parallax/jsPDF · error · Error
Invalid argument passed to jsPDF.setLineMiterLimit
Error message
Invalid argument passed to jsPDF.setLineMiterLimit
What it means
Thrown by setLineMiterLimit (alias setMiterLimit) when the length argument is NaN after the isNaN() check. Note the line `length = length || 0` converts falsy values (0, null, '', undefined) to 0 before the NaN test, so this error only fires when length is a non-numeric truthy value (e.g. a string like 'abc', an object, or an actual NaN produced by arithmetic). The value is then scaled and emitted as the PDF 'M' operator.
Source
Thrown at src/jspdf.js:5511
};
var miterLimit;
/**
* Sets the miterLimit property, which effects the maximum miter length.
*
* @param {number} length The length of the miter
* @function
* @instance
* @returns {jsPDF}
* @memberof jsPDF#
* @name setLineMiterLimit
*/
API.__private__.setLineMiterLimit = API.__private__.setMiterLimit = API.setLineMiterLimit = API.setMiterLimit = function(
length
) {
length = length || 0;
if (isNaN(length)) {
throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit");
}
out(hpf(scale(length)) + " M");
return this;
};
/**
* An object representing a pdf graphics state.
* @class GState
*/
/**
*
* @param parameters A parameter object that contains all properties this graphics state wants to set.
* Supported are: opacity, stroke-opacity
* @constructor
*/
API.GState = GState;View on GitHub (pinned to a3930ce03a)
Solutions
- Pass a plain number, e.g. doc.setLineMiterLimit(5).
- Coerce explicitly before calling: doc.setLineMiterLimit(Number(value)) and guard with !isNaN.
- If value may be a CSS unit string, strip the unit and parse float first.
Example fix
// before doc.setLineMiterLimit(input.value); // input.value === '5px' // after var v = parseFloat(input.value); doc.setLineMiterLimit(isNaN(v) ? 0 : v);
Defensive patterns
Strategy: validation
Validate before calling
var n = Number(value); if (!isNaN(n)) doc.setLineMiterLimit(n);
Type guard
function isFiniteNumber(v){ return typeof v === 'number' && isFinite(v); } Try / catch
try { doc.setLineMiterLimit(value); } catch (e) { if (/setLineMiterLimit/.test(e.message)) doc.setLineMiterLimit(0); else throw e; } Prevention
- Always parseFloat user input
- Never pass CSS unit strings to numeric PDF APIs
When it happens
Trigger: Calling doc.setLineMiterLimit('abc'), doc.setLineMiterLimit(NaN) where NaN is truthy-impossible (NaN is falsy... actually NaN is falsy so length||0 makes it 0, so NaN never reaches the throw). Calling with an object, array, or non-empty non-numeric string that survives the || 0 coercion. Arithmetic that yields a non-numeric truthy value.
Common situations: Reading miter limit from an unvalidated text input; passing a unit-string like '5px' instead of a number; chaining calculations where an intermediate produced a truthy non-number.
Related errors
- Line join style of '" + style + "' is not recognized. See or
- Invalid coordinates passed to jsPDF.addSvgAsImage
- Invalid measurements (width and/or height) passed to jsPDF.a
- Invalid arguments passed to PubSub.subscribe (jsPDF-module)
- Invalid Combination of fontweight and fontstyle
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/75854bbf19800cdd.
Report an issue: GitHub.