harttle/liquidjs

Unexpected "RenderError: memory alloc limit exceeded"

jg-rp opened this issue · 0 comments

Since e443068, I'm getting "RenderError: memory alloc limit exceeded" from the following example.

import { Liquid } from "liquidjs";

const liquid = new Liquid();
const context = { x: ["a", "b"] };
const template = "{{ x | join: 5 }}";  // non-string argument
liquid.parseAndRender(template, context).then(console.log);

Output

memory alloc limit exceeded, line:1, col:1
>> 1| {{ x | join: 5 }}
      ^
RenderError: memory alloc limit exceeded, line:1, col:1
    at Render.renderTemplates (/home/james/tmp/liquidjs_usage/node_modules/liquidjs/dist/liquid.node.cjs.js:1204:53)
    at renderTemplates.throw (<anonymous>)
    at toPromise (/home/james/tmp/liquidjs_usage/node_modules/liquidjs/dist/liquid.node.cjs.js:520:32)
From AssertionError: memory alloc limit exceeded
.
.
.

Previously, the same template would output:

a5b

And the error message produced by {{ 123 | uniq }} has changed from:

RenderError: (arr || []).filter is not a function

to

RenderError: memory alloc limit exceeded

(Shopify/Liquid would coerce 123 to as single element array ([123]) and result in 123)