Skip to content

Commit

Permalink
fix: use setTimeout Promise (#58)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Introduced a custom sleep function for handling delays.
- Added a new GitHub Actions workflow for continuous integration with
Node.js 14.

- **Bug Fixes**
- Maintained existing error handling for retry logic in the waitPort
function.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Dec 8, 2024
1 parent b2cf1bb commit db3ce1b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/nodejs-14.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node.js 14 CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: irby/setup-node-nvm@master
with:
node-version: '16.x'
- run: npm install
- run: npm run prepublishOnly
- run: node -v
- run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 && node -v && node dist/commonjs/bin/detect-port.js
7 changes: 6 additions & 1 deletion src/wait-port.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { debuglog } from 'node:util';
import { setTimeout as sleep } from 'node:timers/promises';
import detectPort from './detect-port.js';

const debug = debuglog('detect-port:wait-port');

function sleep(ms: number) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}

export class WaitPortRetryError extends Error {
retries: number;
count: number;
Expand Down

0 comments on commit db3ce1b

Please sign in to comment.