Skip to content

Fix emoji loading race conditions

What does this MR do and why?

Support Vite in feature tests

Add patch, so that vue_ruby can be configured from config

Add new test cases for emoji caching

Our caching of emoji in localStorage is tricky and barely tested. This adds the following test cases:

  • when the localStorage is empty
  • when the localStorage stores the correct version
  • when the localStorage stores an incorrect version

These cases are handled fine currently. The following cases are not handled well today:

  1. when the localStorage contains garbage data (e.g. it got corrupted or manipulated somehow). We currently do not catch the error.
  2. when the localStorage cannot save the item. We thought we handled the case correctly, but: We first try to save the EMOJI_VERSION in localStorage and then the big blob. So if the saving fails, we have updated the version but not the blob.

Fix emoji loading race conditions

  1. If the JSON data is corrupted.
  2. If the JSON data cannot be saved to localStorage because it is too large. This race condition forces us to bump the CACHE_VERSION_KEY because users actively run into this in the wild.

Related to #430754 (closed)

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Checkout 243729f54544a4a6332687c5488360cbebeb8eea and run yarn run jest --watch spec/frontend/emoji/index_spec.js
  2. See the failing specs
  3. Checkout the latest commit

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Heinrich Lee Yu

Merge request reports