Skip to content

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

Description

@bertrandE

Software versions

  • OS: MacOS 14.6.1
  • Pact library: @pact-foundation/pact@15.0.1
  • 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviortriageThis issue is yet to be triaged by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions