Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some others flaky tests #1808

Merged
merged 4 commits into from
Mar 13, 2024
Merged

fix: some others flaky tests #1808

merged 4 commits into from
Mar 13, 2024

Conversation

robertsLando
Copy link
Member

No description provided.

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 79.45%. Comparing base (2b75186) to head (e8462b3).

Files Patch % Lines
src/lib/timers.ts 71.42% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1808      +/-   ##
==========================================
+ Coverage   79.40%   79.45%   +0.04%     
==========================================
  Files          24       25       +1     
  Lines        1423     1426       +3     
  Branches      332      332              
==========================================
+ Hits         1130     1133       +3     
  Misses        212      212              
  Partials       81       81              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robertsLando
Copy link
Member Author

robertsLando commented Mar 5, 2024

@mcollina I recently started to randomly get this error on tests: https://github.com/mqttjs/MQTT.js/actions/runs/8143942807/job/22256983402?pr=1808#step:6:188

  'test did not finish before its parent and was cancelled'

Any clue?

@robertsLando
Copy link
Member Author

@mcollina It seems this happens very randomly, initially I thought that it was caused by a leaked handler but I have been able to reproduce it locally by running tests on a single file and it fails after few seconds (when it happens). It makes me thinking about a possible race condition in tests but I have no clue where to look/debug

mcollina
mcollina previously approved these changes Mar 5, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@robertsLando
Copy link
Member Author

@mcollina the issue is not fixed btw, I still get that error randomly...

@robertsLando robertsLando requested a review from mcollina March 6, 2024 15:07
@mcollina
Copy link
Member

mcollina commented Mar 7, 2024

The tests are not properly isolated due to them running against the same broker and in the same process. porting them to tap or node:test would fix the latter, and a major refactoring would fix the former. Otherwise this is a goose chase.

@robertsLando
Copy link
Member Author

robertsLando commented Mar 7, 2024

The tests are not properly isolated due to them running against the same broker and in the same process. porting them to tap or node:test would fix the latter

Maybe you forgot about: #1697 that exaxtly did such things

  1. Each test is using a different broker on a different port:

This is the method used:

export default function getPorts(i = 0) {

Then each file requires a different port like:

const ports = getPorts(5)

  1. Tests are already using node:test suite:

import { run } from 'node:test'

As you can see also the test suite are run in parallel

@robertsLando
Copy link
Member Author

@mcollina Ping

@robertsLando
Copy link
Member Author

@mcollina I will merge this for now as it makes some improvements I wish to include on next release, if you find some time to check the code and find a possible reason why that error happens let me know 🙏🏼

@robertsLando robertsLando merged commit f988058 into main Mar 13, 2024
8 checks passed
@robertsLando robertsLando deleted the fix-flaky-tests branch March 13, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants