mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Previously, `loadLibs` was called inside the `optimize` function of the media-optimization-worker, which meant that it could be hit multiple times causing load errors (as seen inb69c2f7311) This commit moves that call to a specific message handler (the `install` message) for the service worker, and refactors the service for the media-optimization-worker to wait for this installation to complete before continuing with processing image optimizations. This way, we know for sure based on promises and worker messages that the worker is installed and has all required libraries loaded before we continue on with attempting any processing. The change made inb69c2f7311is no longer needed with this commit.