Skip to content

Global tracing subscriber error on pact-js with Jest when --watch or --watchAll is enabled #1438

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

Open
5 tasks done
bertrandE opened this issue Mar 31, 2025 · 0 comments
Open
5 tasks done
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@bertrandE
Copy link

bertrandE commented Mar 31, 2025

Software versions

  • OS: MacOS 14.6.1
  • Pact library: @pact-foundation/[email protected]
  • Node Version: Node 22.11.0

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

When running the tests, no error should be shown.

Actual behaviour

When running the tests using Jest / Pact-js, the following error is reported before (or after?) every test:

Failed to initialise global tracing subscriber - a global default trace dispatcher has already been set

The reference implementation has several places where this could come from:
https://github.com/search?q=repo%3Apact-foundation%2Fpact-reference%20set_global_default&type=code

This seems to be linked to the --watch or --watchAll flag as when I run without them, no error is reported.

Note that this does not seem to influence the execution of the tests (they run just as well).

Am I right to assume that this global default trace dispatcher is linked to the telemetry that pact collects and that setting the PACT_DO_NOT_TRACK =true env var should disable it? I tried it without success.

Steps to reproduce

I have gathered a minimal reproductible repo here:
https://github.com/bertrandE/jest-global-tracing-repro/tree/main

Just run npm run test.

The logs of the execution:

 PASS  src/b.pact.jest.ts
  Suite B
    ✓ Test B (349 ms)

Failed to initialise global tracing subscriber - a global default trace dispatcher has already been set
 PASS  src/a.pact.jest.ts
  Suite A
    ✓ Test A (6 ms)

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        1.336 s

Relevant log files

debug.txt

@bertrandE bertrandE added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant