liquid icon indicating copy to clipboard operation
liquid copied to clipboard

The inclusions of .errors makes Liquid::Template non thread-safe?

Open gja opened this issue 9 years ago • 1 comments

Hey All,

Since one of the core goals of liquid is to be a compilable resource, it would be assumed that one would use it something like this

# During application warmup
template = Liquid::Template.parse(something)

# And then, during runtime, in many different code paths
template.render({foo: "bar"})
template.render({foo: "baz})

However, since templates sets errors, this makes it inherently thread-unsafe. However, render! seems to be safer (all threads will set @rethrow_errors = true, and bubble up exceptions without any mutation)

Is this by design? Or am i doing something wrong?

gja avatar May 29 '16 13:05 gja

Indeed render still does:

ensure
  @errors = context.errors
end

juharris avatar Apr 22 '25 13:04 juharris