← Back to release summary

Support Web Locks API in Shared Storage

Category
Offline / Storage
Type
New or changed feature
Status
Enabled by default (Chrome 134)
Intent stage
None

Summary

Today, concurrent execution of shared storage worklets in scenarios like cross-site reach measurement can result in duplicate reporting, due to the potential race conditions within the "get() and set()" logic. To address this issue, we propose integrating the Web Locks API into Shared Storage. Specifically, - Introduce navigator.locks.request to the worklet environment. - Introduce { withLock: <resource>} option to all modifier methods. - Introduce a batch modify method: sharedStorage.batchUpdate(methods, options). This method, with the 'withLock' option, allows multiple modifier methods to be executed atomically, enabling use cases where a website needs to maintain consistency while updating data organized across multiple keys.

Standards & signals

Explainers: https://github.com/WICG/shared-storage/pull/199

View on chromestatus.com