Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-worker computeWorkerKey option not always grouping #5956

Closed
kassens opened this issue Apr 10, 2018 · 6 comments · Fixed by #6073
Closed

jest-worker computeWorkerKey option not always grouping #5956

kassens opened this issue Apr 10, 2018 · 6 comments · Fixed by #6073
Assignees

Comments

@kassens
Copy link

kassens commented Apr 10, 2018

The cache for making workers of jest-worker sticky to a worker using computeWorkerKey seems to only be set in the callback (code). In this example, even though computeWorkerKey is a function returning a constant, multiple workers are created.

This seems unintended?

const Worker = require('jest-worker').default;

async function main() {
  const myWorker = new Worker(require.resolve('./worker'), {
    computeWorkerKey: (method, ...args) => 'constant',
  });

  const workItems = new Set(['foo', 'bar', 'baz']);

  for (const workItem of workItems) {
    console.log('start', workItem);
    myWorker.transform('/tmp/foo.js').then(res => {
      console.log('done', workItem);
    })
  }

  myWorker.end();
}

main().then(undefined, err => {
  console.log(err);
});
@mjesun
Copy link
Contributor

mjesun commented Apr 10, 2018

Nope, you are right! I think @BYK was working on a fix for this a few weeks ago :)

@mjesun
Copy link
Contributor

mjesun commented Apr 25, 2018

@BYK will you be able to take a look at this?

@mjesun mjesun assigned rafeca and unassigned BYK and mjesun Apr 26, 2018
@mjesun
Copy link
Contributor

mjesun commented Apr 26, 2018

@kassens So @rafeca will take the task as an introductory one for Jest. Sorry about the delay!

@kassens
Copy link
Author

kassens commented Apr 27, 2018

I didn't end up using it more, but might have caused some unintended perf regressions somewhere :)

@mjesun
Copy link
Contributor

mjesun commented Apr 27, 2018

Well, anyway, it's fixed 🙂 Sorry for the long time to take care of this!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants