Expected behavior: WorkerServer.join() works correctly
Actual behavior: The program would be destroyed before
WorkerServer is a class constructed in the Worker instance. The Worker instance would be destroyed directly when the main program closes it. Thus, WorkerServer.join() cannot be run. Also, SharedWorkerAcceptor.join() does not work when the exited client was the last browser.
Code occuring the bug
index.ts
import { WorkerConnector } from "tgrid/protocols/workers/WorkerConnector";
async function main(): Promise<void>
{
let connector: WorkerConnector();
await connector.connect(__dirname + "/server.js");
await connector.join();
}
main();
server.ts
import { WorkerServer } from "tgrid/protocols/workers/WorkerServer";
async function main(): Promise<void>
{
let server: WorkerServer = new WorkerServer();
await server.open();
await server.join();
console.log("Cannot reach to this code");
console.log("The program would be terminated before");
}
main();
Summary
WorkerServer is a class constructed in the Worker instance. The Worker instance would be destroyed directly when the main program closes it. Thus,
WorkerServer.join()
cannot be run. Also,SharedWorkerAcceptor.join()
does not work when the exited client was the last browser.Code occuring the bug
index.ts
server.ts