'Do web workers allow you to go over the browser http connection limit?

There are a few questions on SO related to web worker http limits, including: Http connection limit on webworker or service worker, Maximum number of http requests using web workers, Http connection limits of webworker, Opinion about synchronous requests in web workers, and Web Worker effect on max http connections on per browser per domain

They each provide conflicting answers as to whether web workers allow a dev to bypass http connection limits. The first has no answer, the second answers negative, the third answers negative (but then a comment answers positive), the fourth is sorta unrelated but a comment answers positive, and the fifth is also positive. Notably, none of these point to anything like official documentation, which as far as I can tell does not exist.

So lots of interest, no clear answer!

I wrote a test myself that answers in the NEGATIVE, but I want to confirm with the community if there is anything I am missing.

server.py

from flask import Flask, render_template, jsonify
from flask_cors import CORS

app = Flask(__name__, static_folder='templates', template_folder='templates')
CORS(app)


@app.route('/')
def index(name=None):
  return render_template('index.html', name=name)

app.run(debug=True, port=8080, host='0.0.0.0')

templates/index.html

<div>Test whether webworkers bypass the 6-connection http limit</div>
<div>
  Make sure to disable caching for this to work (see: devtools -- gear icon -- network settings --
  disable cache)
</div>

<script src="templates/index.js"></script>

templates/index.js

for (let i = 0; i < 3; ++i) {
  console.log('Creating worker: ', i);
  const worker = new Worker('templates/worker-fast.js');

  worker.addEventListener(
    'message',
    function (e) {
      console.log('Worker said: ', e.data);
    },
    false,
  );

  worker.postMessage('I am worker: ' + i); // Send data to our worker.
}

templates/worker-fast.js

self.addEventListener(
  'message',
  function (e) {
    console.log(e);

    for (let i = 0; i < 6; ++i) {
      fetch(
        '<fetch a big binary from an s3 bucket>',
      ).then(() => {
        self.postMessage('Got image');
      });
    }

    console.log(e.data);
  },
  false,
);

This resulted in the following waterfall: waterfall

Which seems pretty unambiguous that web workers do NOT allow more than 6 connections.

Still. I might just be in denial, but I'm wondering if I did something incorrect in how I set up the workers, as this is the first time I've played with web workers at all.

Has anyone managed to get webworkers (or service workers) to go past the browser http request limit?

(For reference, tests were done on chrome on Ubuntu)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source