DataDog / dd-trace-js

JavaScript APM Tracer
https://docs.datadoghq.com/tracing/
Other
647 stars 306 forks source link

TypeError: Cannot read property 'finish' of undefined #2989

Closed mvargeson closed 1 year ago

mvargeson commented 1 year ago

Expected behaviour

The jest plugin doesn't have a TypeError

Actual behaviour

/home/circleci/repo/node_modules/dd-trace/packages/datadog-plugin-jest/src/index.js:34
          this.testSuiteSpan.finish()
                             ^

TypeError: Cannot read property 'finish' of undefined
    at process.handler (/home/circleci/repo/node_modules/dd-trace/packages/datadog-plugin-jest/src/index.js:34:30)
    at process.emit (node:events:406:35)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

Steps to reproduce

This error shows at the end of the output when running jest tests in CI. This error only started showing up after upgrading from version 3.15.0 to 3.16.0. My assumption is that it has something to do with this change possibly.

Environment

juan-fernandez commented 1 year ago

hey @mvargeson ! Thanks for the report. Is there any chance for you to provide a small reproducible case? The fix should be simple, but I'd want to know when this happens so that I can test against it.

Are you by any chance using jest-jasmine2 as your testRunner? That's the default in jest@26.6.3, so if you haven't configured any other, that's the one you're using.

mvargeson commented 1 year ago

Hi @juan-fernandez, thanks for the quick reply ❤️ Yes, correct in that we are using jest-jasmine2. The error should pop up with those versions during any test run, but I can get a repro repo put together next week if that helps.

juan-fernandez commented 1 year ago

Hi @juan-fernandez, thanks for the quick reply ❤️ Yes, correct in that we are using jest-jasmine2. The error should pop up with those versions during any test run, but I can get a repro repo put together next week if that helps.

I've managed to reproduce semi-consistently, but not quite 100%. I guess the way jest sends signals to its worker is not 100% consistent. If you can create a repro repo that fails 100% of the times that'd be awesome 😄