mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 11:58:27 +00:00
2461ed303c
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 in b69c2f7311836b8e35719a4d24cb60020fd7234d) 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 in b69c2f7311836b8e35719a4d24cb60020fd7234d is no longer needed with this commit.