Skip to content
Snippets Groups Projects

Fix broken web workers when using CDN

Merged Mike Greiling requested to merge revert-e4b2c3b0 into master
All threads resolved!

What does this MR do?

In order to work around web workers same-origin policy, we must override the CDN settings on pages which utilize web workers. The is done by overriding __webpack_public_path__ which sets the base path for all dynamically loaded javascript assets at runtime.

The monaco-editor-webpack-plugin has a bug in which it tries to reference this path in the global scope (window.__webpack_public_path__) instead of as a free variable (__webpack_public_path__) – see https://github.com/Microsoft/monaco-editor-webpack-plugin/pull/63 . In !26015 (merged) we edited our workaround to set the globally scoped variable to fix the IDE, but this in turn broke our non-monaco web workers which were relying on the old behavior.

This MR reverts the changes in !26015 (merged) by removing the deleted lines and adding a note above our workaround line for the monaco plugin so that we can remove it once the bug is fixed upstream.

Original Description:

__webpack_public_path__ must be a "free variable" according to the documentation. It does not exist on the global scope, and setting window.__webpack_public_path__ will have no effect.

Effectively this change disabled the setting of __webpack_public_path__ prior to loading the IDE assets. If doing so managed to fix the issue, we ought to be explicit about it and just remove the line altogether. However I believe that will introduce other problems, as the reason it was here in the first place was to ensure the web worker scripts bypass CDN settings since they do not work cross-origin. I suggest reverting for now and re-forming a new solution.

/cc @iamphill @filipa

What are the relevant issue numbers?

Re-opens #50451 (closed)

Closes: gitlab-org/gitlab-ce#60217

Edited by Mike Greiling

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Reviewer roulette

    Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.

    To spread load more evenly across eligible reviewers, Danger has randomly picked a candidate for each review slot. Feel free to override this selection if you think someone else would be better-suited, or the chosen person is unavailable.

    Once you've decided who will review this merge request, mention them as you normally would! Danger does not (yet?) automatically notify them for you.

    Category Reviewer Maintainer
    frontend Martin Wortschack (@wortschi) Filipa Lacerda (@filipa)

    Generated by :no_entry_sign: Danger

    Edited by 🤖 GitLab Bot 🤖
  • Mike Greiling resolved all discussions

    resolved all discussions

  • I tried to test this by changing config.action_controller.asset_host = 'localhost.me:3000'. While the CSS loaded fine, it looks like Webpack was confused by host vs. URL:

    image`

    I'm inclined just merge this and get a build running on staging ASAP.

  • Ok, this is the right config:

    config.action_controller.asset_host = 'http://localhost.me:3000'

    I also had to disable inlining:

    diff --git a/config/webpack.config.js b/config/webpack.config.js
    index 19b48845305..41ca722844a 100644
    --- a/config/webpack.config.js
    +++ b/config/webpack.config.js
    @@ -172,7 +172,7 @@ module.exports = {
                 loader: 'worker-loader',
                 options: {
                   name: '[name].[hash:8].worker.js',
    -              inline: IS_DEV_SERVER,
    +              inline: false,
                 },
               },
               'babel-loader',

    Without this MR, I replicated the error on staging:

    image

    • Resolved by Stan Hu

      With this MR in my dev environment, I got a slightly different URL:

      image

      Is this just an issue with a local dev environment?

  • Stan Hu resolved all discussions

    resolved all discussions

  • Stan Hu approved this merge request

    approved this merge request

  • Stan Hu enabled an automatic merge when the pipeline for 596d5fa2 succeeds

    enabled an automatic merge when the pipeline for 596d5fa2 succeeds

  • Stan Hu resolved all discussions

    resolved all discussions

  • Mike Greiling changed the description

    changed the description

  • Stan Hu canceled the automatic merge

    canceled the automatic merge

  • merged

  • Stan Hu mentioned in commit 5cc1d2f1

    mentioned in commit 5cc1d2f1

  • Mike Greiling changed title from Revert "Merge branch 'fix-ide-web-worker-relative-url' into 'master'" to Fix broken web workers when using CDN

    changed title from Revert "Merge branch 'fix-ide-web-worker-relative-url' into 'master'" to Fix broken web workers when using CDN

  • Automatically picked into https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27157, will merge into 11-10-stable ready for 11.10.0-rc4.

  • GitLab Release Tools Bot removed 1 deleted label

    removed 1 deleted label

  • Stan Hu mentioned in commit 9f38d3db

    mentioned in commit 9f38d3db

  • mentioned in merge request !27157 (merged)

  • Please register or sign in to reply
    Loading