isol8 0.3.0 → 0.3.1

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/dist/cli.js CHANGED
@@ -55018,6 +55018,7 @@ class ContainerPool {
55018
55018
  createOptions;
55019
55019
  pools = new Map;
55020
55020
  replenishing = new Set;
55021
+ pendingReplenishments = new Set;
55021
55022
  constructor(options) {
55022
55023
  this.docker = options.docker;
55023
55024
  this.poolSize = options.poolSize ?? 2;
@@ -55067,6 +55068,7 @@ class ContainerPool {
55067
55068
  await Promise.all(promises);
55068
55069
  }
55069
55070
  async drain() {
55071
+ await Promise.all(this.pendingReplenishments);
55070
55072
  const promises = [];
55071
55073
  for (const [, pool] of this.pools) {
55072
55074
  for (const entry of pool) {
@@ -55081,26 +55083,20 @@ class ContainerPool {
55081
55083
  ...this.createOptions,
55082
55084
  Image: image
55083
55085
  });
55084
- console.log(`[Pool] Container ${container.id} created for image: ${image}`);
55085
55086
  await container.start();
55086
- console.log(`[Pool] Container ${container.id} started.`);
55087
55087
  return container;
55088
55088
  }
55089
55089
  replenish(image) {
55090
55090
  if (this.replenishing.has(image)) {
55091
- console.log(`[Pool] Replenishment for ${image} already in progress.`);
55092
55091
  return;
55093
55092
  }
55094
55093
  this.replenishing.add(image);
55095
- console.log(`[Pool] Starting background replenishment for image: ${image}`);
55096
- this.createContainer(image).then((container) => {
55094
+ const promise = this.createContainer(image).then((container) => {
55097
55095
  const pool = this.pools.get(image) ?? [];
55098
55096
  if (pool.length < this.poolSize) {
55099
55097
  pool.push({ container, createdAt: Date.now() });
55100
55098
  this.pools.set(image, pool);
55101
- console.log(`[Pool] Replenished container ${container.id} added to pool for ${image}. Current pool size: ${pool.length}`);
55102
55099
  } else {
55103
- console.log(`[Pool] Replenished container ${container.id} not needed (pool for ${image} is full), destroying.`);
55104
55100
  container.remove({ force: true }).catch((err) => {
55105
55101
  console.error(`[Pool] Error destroying unneeded replenished container ${container.id}:`, err);
55106
55102
  });
@@ -55109,7 +55105,9 @@ class ContainerPool {
55109
55105
  console.error(`[Pool] Error during replenishment for ${image}:`, err);
55110
55106
  }).finally(() => {
55111
55107
  this.replenishing.delete(image);
55108
+ this.pendingReplenishments.delete(promise);
55112
55109
  });
55110
+ this.pendingReplenishments.add(promise);
55113
55111
  }
55114
55112
  }
55115
55113
 
@@ -61507,4 +61505,4 @@ if (!process.argv.slice(2).length) {
61507
61505
  }
61508
61506
  program2.parse();
61509
61507
 
61510
- //# debugId=1EC5CA4C4BAF17C964756E2164756E21
61508
+ //# debugId=32DEDFAE67B3C8B564756E2164756E21