Fix performance issue with handling large messages

This commit is contained in:
Daniel Huigens 2018-10-19 15:09:33 +02:00
parent 6f9670cc65
commit baaa0716b4
2 changed files with 2 additions and 2 deletions

View File

@ -629,7 +629,7 @@ async function convertStream(data, streaming) {
* @returns {Object} the data in the respective format * @returns {Object} the data in the respective format
*/ */
async function convertStreams(obj, streaming, keys=[]) { 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 await Promise.all(Object.entries(obj).map(async ([key, value]) => { // recursively search all children
if (util.isStream(value) || keys.includes(key)) { if (util.isStream(value) || keys.includes(key)) {
obj[key] = await convertStream(value, streaming); obj[key] = await convertStream(value, streaming);

View File

@ -102,7 +102,7 @@ export default {
* @returns {Object} * @returns {Object}
*/ */
restoreStreams: function(obj) { 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 Object.entries(obj).forEach(([key, value]) => { // recursively search all children
if (MessagePort.prototype.isPrototypeOf(value)) { if (MessagePort.prototype.isPrototypeOf(value)) {
obj[key] = new ReadableStream({ obj[key] = new ReadableStream({