Inertia.js Concurrency: Shared Data Merging Behavior
0 reputation · 20 Mar 2020, 22:53 UTC
Uncertainty About Shared Data Merging in Concurrent Scenarios
Inertia.js exposes a shared data feature that automatically injects specified key/value pairs into every page response. The library merges these shared entries with page‑specific props before rendering. However, the documentation does not specify how this merge behaves when multiple concurrent requests modify the same shared key.
Because Inertia’s request handling is stateless and runs in a concurrent environment (e.g., Node.js event loop or PHP‑FPM workers), a race condition could arise: one request might overwrite a shared key before another has finished processing, leading to an unpredictable final value.
What is the current behavior of Inertia's shared data merging when two simultaneous requests attempt to set the same shared key? Does Inertia guarantee atomicity for shared data updates, or must developers implement custom synchronization? If the behavior is unspecified, is there an upcoming or recommended approach to ensure consistency?