Shopify / Shopify/liquid

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

Open
#759 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the behavior described around Liquid::Template.parse, template.render, render!, and the template errors state. Determine whether concurrent rendering can mutate shared errors, then document whether this is by design and what behavior would constitute a safe resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.