@applitools/ec-client 1.6.1 → 1.6.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.6.2](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ec-client@1.6.1...js/ec-client@1.6.2) (2023-07-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * fixed issue that caused creation of unnecessary tunnels ([b38fe37](https://github.com/applitools/eyes.sdk.javascript1/commit/b38fe3754f97c5f312ceffd74406255654466ab7))
9
+ * start tunnels with proper regional server ([2a34ed8](https://github.com/applitools/eyes.sdk.javascript1/commit/2a34ed8cd72dc9ac54957348cbe8ba9e67032340))
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * @applitools/core-base bumped from 1.3.0 to 1.4.0
15
+ #### Features
16
+
17
+ * support custom property per renderer ([#1715](https://github.com/applitools/eyes.sdk.javascript1/issues/1715)) ([8cf6b1f](https://github.com/applitools/eyes.sdk.javascript1/commit/8cf6b1fb0563b2485ca18eebc2efd236c2287db8))
18
+
19
+
20
+
21
+ * @applitools/image bumped from 1.0.36 to 1.1.0
22
+ #### Features
23
+
24
+ * prevent animated gif images from playing in ufg ([#1721](https://github.com/applitools/eyes.sdk.javascript1/issues/1721)) ([30f39cc](https://github.com/applitools/eyes.sdk.javascript1/commit/30f39cc8ef2cdfa1d85bd7a0037b818db1b52e1b))
25
+ * @applitools/tunnel-client bumped from 1.0.1 to 1.0.2
26
+ #### Bug Fixes
27
+
28
+ * start tunnels with proper regional server ([2a34ed8](https://github.com/applitools/eyes.sdk.javascript1/commit/2a34ed8cd72dc9ac54957348cbe8ba9e67032340))
29
+
3
30
  ## [1.6.1](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ec-client@1.6.0...js/ec-client@1.6.1) (2023-07-05)
4
31
 
5
32
 
@@ -73,8 +73,8 @@ function makeStartSession({ settings, req, tunnels }) {
73
73
  }
74
74
  if (options.tunnel && tunnels) {
75
75
  // TODO should be removed once tunnel spawning issue is solved
76
- await (0, execution_grid_tunnel_1.prepareEnvironment)();
77
- session.tunnels = await tunnels.acquire(session.credentials);
76
+ await (0, execution_grid_tunnel_1.prepareEnvironment)({ egTunnelManagerUrl: session.serverUrl });
77
+ session.tunnels = await tunnels.acquire({ ...session.credentials, tunnelServerUrl: session.serverUrl });
78
78
  }
79
79
  const applitoolsCapabilities = Object.fromEntries([
80
80
  ...Object.entries(options).map(([key, value]) => [`applitools:${key}`, value]),
@@ -54,6 +54,7 @@ async function makeTunnelManager({ settings, logger, }) {
54
54
  exports.makeTunnelManager = makeTunnelManager;
55
55
  function makePool(options) {
56
56
  const pool = new Map();
57
+ const pending = new Set();
57
58
  return {
58
59
  acquire,
59
60
  add,
@@ -65,12 +66,29 @@ function makePool(options) {
65
66
  async function acquire(resourceOptions) {
66
67
  let resource = await get();
67
68
  if (!resource) {
68
- resource = await options.create(resourceOptions);
69
+ resource = await create(resourceOptions);
69
70
  await add(resource);
70
71
  }
71
72
  await use(resource);
72
73
  return resource;
73
74
  }
75
+ async function create(resourceOptions) {
76
+ const availableItem = [...pending].reduce((availableItem, item) => {
77
+ return (!options.maxInuse || item.waiting < options.maxInuse) &&
78
+ (!availableItem || availableItem.waiting > item.waiting)
79
+ ? item
80
+ : availableItem;
81
+ }, null);
82
+ if (availableItem) {
83
+ availableItem.waiting += 1;
84
+ return availableItem.resource;
85
+ }
86
+ const resource = options.create(resourceOptions);
87
+ const item = { resource, waiting: 1 };
88
+ resource.finally(() => pending.delete(item));
89
+ pending.add(item);
90
+ return resource;
91
+ }
74
92
  async function add(resource) {
75
93
  var _a, _b;
76
94
  const item = {
@@ -87,11 +105,13 @@ function makePool(options) {
87
105
  }
88
106
  async function get() {
89
107
  var _a;
90
- const freeItem = Array.from(pool.values()).reduce((freeItem, item) => !item.destroyed &&
91
- (!options.maxInuse || item.inuse < options.maxInuse) &&
92
- (!freeItem || freeItem.inuse > item.inuse)
93
- ? item
94
- : freeItem, null);
108
+ const freeItem = [...pool.values()].reduce((freeItem, item) => {
109
+ return !item.destroyed &&
110
+ (!options.maxInuse || item.inuse < options.maxInuse) &&
111
+ (!freeItem || freeItem.inuse > item.inuse)
112
+ ? item
113
+ : freeItem;
114
+ }, null);
95
115
  return (_a = freeItem === null || freeItem === void 0 ? void 0 : freeItem.resource) !== null && _a !== void 0 ? _a : null;
96
116
  }
97
117
  async function use(resource) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/ec-client",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -52,14 +52,14 @@
52
52
  "test:it": "MOCHA_GROUP=it run --top-level mocha './test/it/*.spec.ts'"
53
53
  },
54
54
  "dependencies": {
55
- "@applitools/core-base": "1.3.0",
55
+ "@applitools/core-base": "1.4.0",
56
56
  "@applitools/driver": "1.13.0",
57
- "@applitools/execution-grid-tunnel": "2.1.6",
57
+ "@applitools/execution-grid-tunnel": "2.1.7",
58
58
  "@applitools/logger": "2.0.5",
59
59
  "@applitools/req": "1.4.0",
60
60
  "@applitools/socket": "1.1.5",
61
61
  "@applitools/spec-driver-webdriver": "1.0.37",
62
- "@applitools/tunnel-client": "1.0.1",
62
+ "@applitools/tunnel-client": "1.0.2",
63
63
  "@applitools/utils": "1.5.0",
64
64
  "abort-controller": "3.0.0",
65
65
  "webdriver": "7",