@remix_labs/machine-starter 2.13006.0-dev → 2.13008.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common.js CHANGED
@@ -21,8 +21,9 @@ class TaskQueue {
21
21
  }
22
22
  run(fn) { // fn shall return a promise. run also returns a promise
23
23
  this.length++;
24
- const result = this.tail.then(() => fn()).finally(() => { this.length--; });
24
+ const result = this.tail.then(() => fn());
25
25
  this.tail = result.catch(() => {});
26
+ this.length--;
26
27
  return result;
27
28
  }
28
29
  }
@@ -67,54 +68,50 @@ function getCoord(vmID) {
67
68
 
68
69
  async function terminateVM(vmID) {
69
70
  let coord = getCoord(vmID);
70
- try {
71
- await coord.queue.run(async () => {
72
- if (!workers[vmID]) return;
73
- console.log("[machine-starter] terminate VM:", vmID);
74
- // make the VM first unknown to the outside and disconnect it,
75
- // then clean up resources (including stopping the VM)
76
- let channel = await last_hub.newChannel();
77
- let topic = worker_topics[vmID];
78
- let payload = { _rmx_type:"msg_vm_register", id: vmID, alive: false };
79
- let msg = channel.newJSONMessage("msg_vm_register", "vm", payload);
80
- await channel.publish(topic + "/announce", msg, true);
81
- // NB. This msg is a leak - it will never be removed.
82
- await channel.disconnect("vm_" + vmID);
83
- // now the VM is isolated and cannot communicate with the
84
- // hub anymore
85
- let worker = workers[vmID];
86
- let vmChildren = children[vmID] || [];
87
- let blobList = blobs[vmID] || [];
88
- let ffiLoop = ffiLoops[vmID];
89
- let blobsLoop = blobsLoops[vmID];
90
- delete children[vmID];
91
- delete ffiLoops[vmID];
92
- delete blobsLoops[vmID];
93
- delete worker_topics[vmID];
94
- delete workers[vmID];
95
- // terminate our endpoints of communication
96
- if (ffiLoop) {
97
- ffiLoop.terminate();
98
- }
99
- if (blobsLoop) {
100
- blobsLoop.terminate();
101
- }
102
- for (let blob_url of blobList) {
103
- console.log("[machine-starter] revoke ", blob_url);
104
- URL.revokeObjectURL(blob_url);
105
- }
106
- // kill the worker:
107
- console.log("[machine-starter] terminate web worker for VM:", vmID);
108
- worker.terminate();
109
- // go on with sub VMs
110
- for (let subID of vmChildren) {
111
- terminateVM(subID) // do not wait
112
- }
113
- });
114
- } finally {
115
- if (coord.queue.length == 0 && coordination[vmID] === coord) {
116
- delete coordination[vmID];
71
+ await coord.queue.run(async () => {
72
+ console.log("[machine-starter] terminate VM:", vmID);
73
+ // make the VM first unknown to the outside and disconnect it,
74
+ // then clean up resources (including stopping the VM)
75
+ let channel = await last_hub.newChannel();
76
+ let topic = worker_topics[vmID];
77
+ let payload = { _rmx_type:"msg_vm_register", id: vmID, alive: false };
78
+ let msg = channel.newJSONMessage("msg_vm_register", "vm", payload);
79
+ await channel.publish(topic + "/announce", msg, true);
80
+ // NB. This msg is a leak - it will never be removed.
81
+ await channel.disconnect("vm_" + vmID);
82
+ // now the VM is isolated and cannot communicate with the
83
+ // hub anymore
84
+ let worker = workers[vmID];
85
+ let vmChildren = children[vmID] || [];
86
+ let blobList = blobs[vmID] || [];
87
+ let ffiLoop = ffiLoops[vmID];
88
+ let blobsLoop = blobsLoops[vmID];
89
+ delete children[vmID];
90
+ delete ffiLoops[vmID];
91
+ delete blobsLoops[vmID];
92
+ delete worker_topics[vmID];
93
+ delete workers[vmID];
94
+ // terminate our endpoints of communication
95
+ if (ffiLoop) {
96
+ ffiLoop.terminate();
97
+ }
98
+ if (blobsLoop) {
99
+ blobsLoop.terminate();
117
100
  }
101
+ for (let blob_url of blobList) {
102
+ console.log("[machine-starter] revoke ", blob_url);
103
+ URL.revokeObjectURL(blob_url);
104
+ }
105
+ // kill the worker:
106
+ console.log("[machine-starter] terminate web worker for VM:", vmID);
107
+ worker.terminate();
108
+ // go on with sub VMs
109
+ for (let subID of vmChildren) {
110
+ terminateVM(subID) // do not wait
111
+ }
112
+ });
113
+ if (coord.queue.length == 0) {
114
+ delete coordination[vmID];
118
115
  }
119
116
  }
120
117
 
@@ -170,11 +167,9 @@ async function StartWASM2(hub, config, getWorker) {
170
167
  console.log("[machine-starter] Call MixExplain() for explaining debug levels, and MixSetMask(m) for changing these")
171
168
  };
172
169
  last_hub = hub;
173
- // get the coord object - perhaps the ID was already used for a VM
170
+ // get thr coord object - perhaps the ID was already used for a VM
174
171
  let coord = getCoord(config.vmID);
175
- return await coord.queue.run(async () => {
176
- if (workers[config.vmID])
177
- throw new Error("[machine-starter] Cannot start VM, the ID is used: " + config.vmID);
172
+ await coord.queue.run(async () => {
178
173
  let channel = await hub.newChannel("vm_" + config.vmID);
179
174
  // injected by either index.js or node.js
180
175
  let worker = await getWorker();
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "13006";
1
+ var GROOVEBOX_BUILD = "13008";
2
2
  export { GROOVEBOX_BUILD }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix_labs/machine-starter",
3
- "version": "2.13006.0-dev",
3
+ "version": "2.13008.0-dev",
4
4
  "description": "start the groove",
5
5
  "main": "node.js",
6
6
  "browser": "index.js",
@@ -11,7 +11,7 @@
11
11
  "author": "Remixlabs staff",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@remix_labs/hub-client": "2.13006.0-dev",
14
+ "@remix_labs/hub-client": "2.13008.0-dev",
15
15
  "nanoid": "^5.0.2",
16
16
  "web-worker": "^1.2.0"
17
17
  },