netlify / gocommerce

A headless e-commerce for JAMstack sites.
MIT License
1.54k stars 208 forks source link

Fix data race in downloads gathering #217

Closed mraerino closed 3 years ago

mraerino commented 3 years ago

- Summary

There was a data race when adding downloads to the order while processing line items.

Fixes https://github.com/netlify/gocommerce-ci/issues/48

- Test plan

Running existing tests with -race uncovered this. Did the same to test the fix.

- Description for the changelog

Fix data race in downloads gathering

- A picture of a cute animal (not mandatory but encouraged)

mraerino commented 3 years ago

does the race happen because the tests run concurrently?

we process the line items in parallel here: https://github.com/netlify/gocommerce/blob/7e033edf5bf0affcbb5ed6f827442151d6c06872/api/order.go#L654-L669