Skip to content

Race condition in processing directories and files #2

@alexewerlof

Description

@alexewerlof

This bug affects all previous versions of combine-json.

If a folder has the following structure:

/parent
  child.json // { "x": "X", "y": "Y" }
  /child/a.json
  /child/b.json
  /child/c.json

Depending on which one gets processed first, the result may be partial. For example if the order is this:

  /child/a.json
  child.json
  /child/b.json
  /child/c.json

Then whatever is set in a.json is ignored. This is due to how lodash.set() works:

const o = {}
_.set(o, ['a', 'b', 'c'], { foo_c: 'bar_c' })
// { a: { b: { c: { foo_c: "bar_c" } } } }
_.set(o, ['a', 'b'], { foo_b: 'bar_b' })
// { a: { b: foo_b: "bar_b" } } } }
// notice that foo_c disappeared!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions