From baaa0716b4c36d0291aad221d10586151d1b5975 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 19 Oct 2018 15:09:33 +0200 Subject: [PATCH] Fix performance issue with handling large messages --- src/openpgp.js | 2 +- src/util.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openpgp.js b/src/openpgp.js index 8fb07ef8..4c671583 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -629,7 +629,7 @@ async function convertStream(data, streaming) { * @returns {Object} the data in the respective format */ async function convertStreams(obj, streaming, keys=[]) { - if (Object.prototype.isPrototypeOf(obj)) { + if (Object.prototype.isPrototypeOf(obj) && !Uint8Array.prototype.isPrototypeOf(obj)) { await Promise.all(Object.entries(obj).map(async ([key, value]) => { // recursively search all children if (util.isStream(value) || keys.includes(key)) { obj[key] = await convertStream(value, streaming); diff --git a/src/util.js b/src/util.js index 495a6260..e2eff20d 100644 --- a/src/util.js +++ b/src/util.js @@ -102,7 +102,7 @@ export default { * @returns {Object} */ restoreStreams: function(obj) { - if (Object.prototype.isPrototypeOf(obj)) { + if (Object.prototype.isPrototypeOf(obj) && !Uint8Array.prototype.isPrototypeOf(obj)) { Object.entries(obj).forEach(([key, value]) => { // recursively search all children if (MessagePort.prototype.isPrototypeOf(value)) { obj[key] = new ReadableStream({