Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

OLX Tech 6 min read Case study mediumAdept

Handling concurrency on the Web with Web Locks API

OLX uses the browser's Web Locks API to stop multiple open tabs from each resuming the same large (up to 20GB) S3 upload after a restart. localStorage-plus-polling suffers from non-atomic writes and stale locks, and BroadcastChannel forces you to hand-roll a coordination protocol, whereas navigator.locks offers an atomic mutex that is released automatically when a tab closes or crashes. A React hook requests the lock with ifAvailable: fresh user-initiated uploads proceed whether or not they get it, restored uploads run only in the tab holding it, and the lock is held until a complete, error, cancel or unmount event. Where the API is unavailable, the hook falls back to allowing restores and accepts the risk of duplicates, and the team reports zero cross-tab duplicate uploads since rollout.

Assumes: JavaScript PromisesReact hooksMutex/lock basics

Related posts

  • Session revocations at scale

    Canva Engineering mediumAdept

    Canva moved its gateway session-revocation cache from per-pod MySQL loads to sorted binary chunks in S3, eliminating the database stampede when hundreds of gateway pods started during deploys. Revocations are packed into 16-byte records in sorted flat arrays split into 30-minute S3 objects. Gateways binary-search the downloaded bytes directly and refresh recent chunks with conditional GETs. A ZooKeeper-elected worker appends new revocations, using conditional PUTs for optimistic concurrency so that racing writers never lose updates. The theoretically O(N^2) rebuild still exceeds 2000 revocations/sec, memory use dropped 87.5%, and read replicas were cut to two.

  • Improved Process Isolation in Firefox 100

    Mozilla Hacks hardMaster

    Firefox 100 enables Win32k Lockdown on Windows, using PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY to block web content processes from calling the historically exploitable win32k.sys kernel APIs. Getting there meant moving every graphics and widget operation out of the content process. Painting moved to WebRender in the GPU process, Canvas 2D is recorded and replayed over IPC, and WebGL gained a validating child/parent API. Form controls are now drawn by Firefox itself instead of as native widgets, complex-script line breaking is forwarded over IPC with caching, and a fix stops injected third-party DLLs from breaking COM. Skipping those DLLs also made opening new tabs about 15% faster, and equivalent lockdowns of WindowServer on macOS and X11 on Linux sped process startup by 30-70% on Mac.

  • Tab Unloading in Firefox 93

    Mozilla Hacks mediumAdept

    Firefox 93 on Windows unloads memory-heavy background tabs in least-recently-used order when system memory is critically low, keeping them in the tab bar and restoring scroll position and form data on reselect. Detection pairs a Windows low-physical-memory notification (CreateMemoryResourceNotification) with periodic checks of available commit space against a configurable threshold, because Windows does not overcommit and allocations fail once commit space runs out, even with free physical RAM. A month-long Nightly experiment showed fewer overall crashes and longer sessions, but higher average memory use (explained by survivorship bias) and a larger share of OOM crashes, possibly because unloading a tab needs a JavaScript GC pass that itself requires memory. Pinned tabs and tabs playing audio, using picture-in-picture or WebRTC are deprioritized, and a new about:unloads page exposes the ordering.

  • Supabase Storage v3: Resumable Uploads with support for 50GB files

    Supabase mediumAdept

    Supabase Storage v3 adds resumable uploads via the open TUS protocol, raising the max file size to 50GB on Pro plans. To scale tus-node-server across load-balanced instances without sticky sessions, Storage uses Postgres transactional advisory locks keyed on a hash of the object path, so only one server writes a given object's chunks to S3 at a time. The release also adds image quality and format transforms with WebP by default, a Next.js image loader, presigned upload URLs, and per-bucket size and MIME-type limits.

  • Learnings from migrating Accessibility Insights for Web to Chrome’s Manifest V3

    Engineering@Microsoft mediumAdept

    Moving the Accessibility Insights for Web extension from Manifest V2 to V3 meant replacing persistent background pages with service workers that can shut down when idle. In-memory state now gets backed up to IndexedDB: it is read once at worker startup and written on every update, and a PR bot flags changes to stored data shapes for backward compatibility. Placeholder event handlers registered on the first event loop defer events until async setup finishes. Content scripts poll runtime.id instead of holding runtime.connect ports, and "fire and forget" onMessage listeners were converted to properly awaited async responses so the worker isn't killed early. Dual MV2/MV3 builds in one repo and separate release channels avoided risky merges and the store's ban on downgrading MV3 extensions to MV2.

The quest for software engineering knowledge.

Look:
Layout: