While using pdfkit, every once in a while I would get this error and the pdf would not come out at all
UnhandledPromiseRejectionWarning: RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 255. Received -1
at writeU_Int8 (internal/buffer.js:555:11)
at Buffer.writeUInt8 (internal/buffer.js:565:10)
at EncodeStream.(anonymous function) [as writeUInt8] (/Users/canda/projects/mural/fontkit/node_modules/restructure/src/EncodeStream.js:37:29)
at NumberT.encode (/Users/canda/projects/mural/fontkit/node_modules/restructure/src/Number.js:28:39)
at Struct.encode (/Users/canda/projects/mural/fontkit/node_modules/restructure/src/Struct.js:110:16)
at RangeArray.ArrayT.encode (/Users/canda/projects/mural/fontkit/node_modules/restructure/src/Array.js:88:19)
at VersionedStruct.encode (/Users/canda/projects/mural/fontkit/node_modules/restructure/src/VersionedStruct.js:120:16)
at VersionedStruct.encode (/Users/canda/projects/mural/fontkit/node_modules/restructure/src/VersionedStruct.js:126:18)
at CFFSubset.encode (/Users/canda/projects/mural/fontkit/index.js:13585:12)
at /Users/canda/projects/mural/fontkit/index.js:13048:13
While using pdfkit, every once in a while I would get this error and the pdf would not come out at all
I narrowed down to fontkit with this short repro.
This is the same error I would get if I try to create a subset from an empty array.
subsetFor("", "output.ttf");