Skip to content

Commit

Permalink
Replace wait-on with wait-port
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador committed Jan 25, 2024
1 parent f2d8a5c commit b69a55a
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 112 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.20.0
v20.11.0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"publish-docs": "GIT_USER=oblador yarn workspace @loki/website publish-gh-pages"
},
"engines": {
"node": ">=16"
"node": ">=20"
},
"author": {
"name": "Joel Arvidsson",
Expand Down Expand Up @@ -55,6 +55,7 @@
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^27.5.1",
"lerna": "^3.22.1",
"node-gyp": "^10.0.1",
"prettier": "^2.6.1"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion packages/target-chrome-docker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"execa": "^5.0.0",
"find-free-port-sync": "^1.0.0",
"fs-extra": "^9.1.0",
"wait-on": "^5.2.1"
"wait-port": "^1.1.0"
},
"publishConfig": {
"access": "public"
Expand Down
28 changes: 7 additions & 21 deletions packages/target-chrome-docker/src/create-chrome-docker-target.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const debug = require('debug')('loki:chrome:docker');
const { execSync } = require('child_process');
const execa = require('execa');
const waitOn = require('wait-on');
const waitPort = require('wait-port');
const CDP = require('chrome-remote-interface');
const getRandomPort = require('find-free-port-sync');
const {
Expand All @@ -22,25 +22,6 @@ const getExecutor = (dockerWithSudo) => (dockerPath, args) => {
return execa(dockerPath, args);
};

const waitOnCDPAvailable = (host, port) =>
new Promise((resolve, reject) => {
waitOn(
{
resources: [`tcp:${host}:${port}`],
delay: 50,
interval: 100,
timeout: 5000,
},
(err) => {
if (err) {
reject(err);
} else {
resolve();
}
}
);
});

function createChromeDockerTarget({
baseUrl = 'http://localhost:6006',
chromeDockerImage = 'yukinying/chrome-headless-browser-stable:118.0.5993.117',
Expand Down Expand Up @@ -151,7 +132,12 @@ function createChromeDockerTarget({

host = await getNetworkHost(execute, dockerId);
try {
await waitOnCDPAvailable(host, debuggerPort);
await waitPort({
host,
port: debuggerPort,
interval: 100,
timeout: 5000,
});
} catch (error) {
if (
error.message.startsWith('Timed out waiting for') &&
Expand Down
Loading

0 comments on commit b69a55a

Please sign in to comment.