Skip to content

Commit

Permalink
fix: race condition (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 authored Jun 24, 2024
2 parents da37ee1 + a1c9d51 commit 1a8bf3e
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/__tests__/*.test.ts
/bin/**/*
/__tests__/*
/bin/**/*
vitest.config.ts
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug Report
about: Report a bug
labels: bug
---

## Search terms

<!-- Include keywords that might help others with the same problem find this issue -->

## Environment

- HL7 Client version:
- TypeScript version:
- Node.js version:
- OS:

Questions:

- Are you using the Node [HL7 Server](https://github.com/Bugs5382/node-hl7-server) package as your HL7 Server to connect to or a 3rd party system?

## Expected Behavior

<!-- How did you expect HL7 Client to work? -->

## Actual Behavior

<!-- What does HL7 Client fail to do? -->

## Steps to reproduce the bug

<!--
Please provide the code causing the issue, as comprehensively as possible.
If the issue is related to a specific HL7 message, please include the actual
message you sent. Ensure that any sensitive information is scrubbed and sanitized before sharing.
-->

11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Question
about: Ask a question
labels: question
---

## Search terms

<!-- Include keywords that might help others with the same question find this issue -->

## Question
21 changes: 16 additions & 5 deletions .github/workflows/dependabot-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
packages: read

jobs:
dependabot:
Dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
Expand All @@ -33,9 +33,20 @@ jobs:
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Enable Auto-Merge for Dependabot PRs
if: ${{ contains(github.event.pull_request.title, 'bump') && contains(github.event.pull_request.title, 'deps-dev') }}
run: gh pr merge --auto --merge "$PR_URL"
- name: Run unit tests
run: |
npm test
- name: Aggregate Dependabot PRs
id: aggregate_prs
run: |
PR_URL=$(gh pr list --json state:open author:dependabot[bot] base:$PR_BASE_BRANCH -q '.[].url' | jq -r 'join(" ")')
echo "::set-output name=pr_url::$PR_URL"
env:
PR_BASE_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Merge aggregated PRs
if: steps.aggregate_prs.outputs.pr_url != ''
run: |
gh pr merge --auto --merge ${{ steps.aggregate_prs.outputs.pr_url }}
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GitHub CI
name: "Deploy: CI"
on:
push:
branches: [ 'main', 'develop' ]
Expand Down Expand Up @@ -32,11 +32,6 @@ jobs:
Release:
runs-on: ubuntu-latest
needs: [ 'Test' ]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Typedoc to GitHub Pages
name: "Deploy: Typedoc to GitHub Pages"

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Lint PR"
name: "PR: Lint Title"

on:
pull_request_target:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/pr-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "PR: Unit Tests"

on:
pull_request:
branches:
- develop
types:
- opened
- synchronize

jobs:
Test:
name: Run Unit tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x, 'lts/*' ]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Run Lint Fix
run: npm run lint:fix
- name: Run Unit Tests
run: npm run test
- name: Check test results
run: exit ${{ steps.Test.outputs.test_result }}
id: check_test_result
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"ts-node": "^10.9.2",
"ts-standard": "^12.0.2",
"tsd": "^0.31.1",
"typedoc": "^0.26.1",
"typedoc": "^0.26.2",
"typescript": "5.5.2",
"vitest": "^1.6.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/client/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export class Connection extends EventEmitter implements IConnection {
})

socket.on('close', () => {
if (this._readyState === ReadyState.CLOSING) {
if (this._readyState === ReadyState.CLOSING || (this._connectionTimer == null)) {
this._readyState = ReadyState.CLOSED
} else {
connectionError = (connectionError != null) ? connectionError : new HL7FatalError('Socket closed unexpectedly by server.')
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"declaration": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
"exclude": ["node_modules", "**/*.test.ts", "__tests__/**/*"]
}
File renamed without changes.

0 comments on commit 1a8bf3e

Please sign in to comment.