Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:50:30+00:00 2026-05-30T00:50:30+00:00

Im trying to create web Workers and post messages to them in cycle: array.forEach(function

  • 0

Im trying to create web Workers and post messages to them in cycle:

array.forEach(function (data) {
        this.createWorker();
        this.workers[this.workersPointer].postMessage({task: 'someTask', data: string});
    }, this);

createWorker function:

createWorker: function () {
    this.workersPointer++;
    var worker = this.workers[this.workersPointer] = new Worker('Worker.js'),
        storage = this;
    worker.onmessage = function (event) {
        if (event.data.error) {
            storage[event.data.task + 'Errback'](event.data.error);
        }
        else {
            storage[event.data.task + 'Callback'](event.data.data);
        }
    };
    worker.onerror = function (error) {
        storage.workerErrback(error);
    };
}

Worker code:

self.addEventListener('message', function (event) {
self.postMessage({
    data: data,
    error: err,
    task: event.data.task
});

}, false);

It works perfectly in Google Chrome. When I’m trying to run it in Firefox, it works only 20 times. Do Firefox web workers have a limit? I can’t find information about it on mozilla.org. If there is no limit, what’s the problem? Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:50:32+00:00Added an answer on May 30, 2026 at 12:50 am

    Just did some test of my own. For this, i changed the code a little bit:

    Cycle:

    for(var i=0;i<200;i++){
       this.createWorker();
       this.workers[this.workersPointer].postMessage({task: 'someTask', number:i});
    };
    

    createWorker function:

    this.workers =[];
    this.workersPointer = 0;
    storage=[];
    
    
    var createWorker= function () {
        workersPointer++;
        var myPointer = workersPointer;
        var worker = this.workers[this.workersPointer] = new Worker('Worker.js');
    
        worker.onmessage = function (event) {
            if (event.data.error) {
                alert(event.data.error);
            }
            else {
                document.cookie=event.data.task+"["+myPointer+"]="+event.data.number;
            }
        };
        worker.onerror = function (event) {
            alert("Error: " + event.error);
        };
    }
    

    Worker:

    onmessage = function(event) {
        postMessage({number:event.data.number*2, task: event.data.task});
    };
    

    After i run this, in chrome i got 66 cookies (including a nice blue crash window), in firefox i got 20. So both browsers seem to have worker limitations.

    EDIT:

    In Opera i get a console message:

    Maximum number of Web Worker instances(16) exceeded for this window.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are trying to create a web-service that we plan to pass a variable
I'm trying to create a web application project template for everyone to use here
I'm trying to create a web application using maven, tomcat and hibernate. Now I'm
I'm trying to create a SharePoint web part that will display all the users
I've been trying to create a stable web service application for the last 2-3
I'm trying to create a small web service to convert PDF files to a
I'm trying to create a rails web app that does not use ActiveRecord framework
I am trying to create an asp.net web form that allows a user to
I am trying to create a set of WCF web services for an existing
I'm trying to create a Palm OS app to check a web site every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.