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

App doesn't exit if specify a worker #315

Open
tylerlong opened this issue Dec 13, 2024 · 1 comment
Open

App doesn't exit if specify a worker #315

tylerlong opened this issue Dec 13, 2024 · 1 comment
Labels

Comments

@tylerlong
Copy link

tylerlong commented Dec 13, 2024

"elkjs": "^0.9.3",

Official sample code copied from readme page:

const ELK = require('elkjs')
const elk = new ELK()

const graph = {
  id: "root",
  layoutOptions: { 'elk.algorithm': 'layered' },
  children: [
    { id: "n1", width: 30, height: 30 },
    { id: "n2", width: 30, height: 30 },
    { id: "n3", width: 30, height: 30 }
  ],
  edges: [
    { id: "e1", sources: [ "n1" ], targets: [ "n2" ] },
    { id: "e2", sources: [ "n1" ], targets: [ "n3" ] }
  ]
}

elk.layout(graph)
   .then(console.log)
   .catch(console.error)

It works very well.

If I specify a worker url:

const ELK = require("elkjs");
const Worker = require("web-worker");

const workers = new Set();

const elk = new ELK({
  workerUrl: require.resolve("elkjs/lib/elk-worker.min.js"),
});

const graph = {
  id: "root",
  layoutOptions: { "elk.algorithm": "layered" },
  children: [
    { id: "n1", width: 30, height: 30 },
    { id: "n2", width: 30, height: 30 },
    { id: "n3", width: 30, height: 30 },
  ],
  edges: [
    { id: "e1", sources: ["n1"], targets: ["n2"] },
    { id: "e2", sources: ["n1"], targets: ["n3"] },
  ],
};

elk
  .layout(graph)
  .then((s) => {
    console.log(s);
    workers.forEach((worker) => worker.terminate());
  })
  .catch(console.error);

It works but it does NOT exit.

Which means the worker is still active.

@tylerlong tylerlong added the bug label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
@tylerlong and others