diff --git a/src/es_archiver/lib/archives/__tests__/parse.js b/src/es_archiver/lib/archives/__tests__/parse.js index 072c7bf99190d..506917cac92cd 100644 --- a/src/es_archiver/lib/archives/__tests__/parse.js +++ b/src/es_archiver/lib/archives/__tests__/parse.js @@ -91,9 +91,9 @@ describe('esArchiver createParseArchiveStreams', () => { createConcatStream([]) ]); - input.write(Buffer.from('{"a": 1}\n\n')); + input.write(Buffer.from('{"a": 1}\n\n{"a":')); expect(await receivedPromise).to.eql({ a: 1 }); - input.write(Buffer.from('{"a": 2}')); + input.write(Buffer.from('2}')); input.end(); expect(await finalPromise).to.eql([{ a: 1 }, { a: 2 }]); }); diff --git a/src/es_archiver/lib/archives/parse.js b/src/es_archiver/lib/archives/parse.js index b0f88d24f7344..db0a2cdc3e280 100644 --- a/src/es_archiver/lib/archives/parse.js +++ b/src/es_archiver/lib/archives/parse.js @@ -22,6 +22,7 @@ import { PassThrough } from 'stream'; import { createSplitStream, + createReplaceStream, createJsonParseStream, } from '../../../utils'; @@ -30,6 +31,7 @@ import { RECORD_SEPARATOR } from './constants'; export function createParseArchiveStreams({ gzip = false } = {}) { return [ gzip ? createGunzip() : new PassThrough(), + createReplaceStream('\r\n', '\n'), createSplitStream(RECORD_SEPARATOR), createJsonParseStream(), ];