diff --git a/CHANGELOG.md b/CHANGELOG.md index c6a1c75..7f0f211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [2.5.2] +### Fixed +- Fixed unhandled promise rejection in `doc.asBuffer()` - take two + ## [2.5.1] ### Fixed - Fixed unhandled promise rejection in `doc.asBuffer()` diff --git a/lib/document.js b/lib/document.js index 1e3e9ca..618cedd 100644 --- a/lib/document.js +++ b/lib/document.js @@ -653,7 +653,7 @@ class Document extends Readable { this.on("end", () => resolve(Buffer.concat(chunks))); this.on("error", reject); if (shouldEnd) { - return this.end(); + this.end().catch(reject); } }); if (typeof callback === "function") { diff --git a/package-lock.json b/package-lock.json index 7f23e2b..b5f8795 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pdfjs", - "version": "2.5.1", + "version": "2.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pdfjs", - "version": "2.5.1", + "version": "2.5.2", "license": "MIT", "dependencies": { "@rkusa/linebreak": "^1.0.0", diff --git a/package.json b/package.json index e2e46fa..5446f0a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pdfjs", "author": "Markus Ast ", - "version": "2.5.1", + "version": "2.5.2", "description": "A Portable Document Format (PDF) generation library targeting both the server- and client-side.", "keywords": [ "pdf", diff --git a/test/others/asBuffer.js b/test/others/asBuffer.js index b1ba24b..ac41e11 100644 --- a/test/others/asBuffer.js +++ b/test/others/asBuffer.js @@ -45,3 +45,22 @@ test("asBuffer", function (t) { }) .catch(t.error); }); + +test("error in pending queue", async function (t) { + t.plan(1); + + let doc = new pdf.Document({ + font: f.font.afm.regular, + }); + + doc._pending.push(() => { + return new Promise(() => { + throw new Error("Test Error"); + }); + }); + + await doc + .asBuffer() + .then(() => t.fail("asBuffer expected to reject")) + .catch(() => t.pass("as Buffer rejected")); +});