From e5b8c61717cf49ea64adf9029f0dd6fe6ffe7d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 5 Jan 2021 08:02:28 +0100 Subject: [PATCH] test: guard large string decoder allocation Use common.enoughTestMem to avoid "Array buffer allocation failed" error on low memory devices. Fixes: https://github.com/nodejs/node/issues/36792 PR-URL: https://github.com/nodejs/node/pull/36795 Reviewed-By: Gireesh Punathil Reviewed-By: Pooja D P Reviewed-By: Antoine du Hamel --- test/parallel/test-string-decoder.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js index 043816bdbb1568..be876f46e5af02 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -201,12 +201,14 @@ assert.throws( } ); -assert.throws( - () => new StringDecoder().write(Buffer.alloc(0x1fffffe8 + 1).fill('a')), - { - code: 'ERR_STRING_TOO_LONG', - } -); +if (common.enoughTestMem) { + assert.throws( + () => new StringDecoder().write(Buffer.alloc(0x1fffffe8 + 1).fill('a')), + { + code: 'ERR_STRING_TOO_LONG', + } + ); +} // Test verifies that StringDecoder will correctly decode the given input // buffer with the given encoding to the expected output. It will attempt all