opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

chore(deps): remove unused cpx dependencies and update used ones to cpx2

Open pichlermarc opened this issue 1 year ago • 6 comments

Which problem is this PR solving?

  • replaces cpx with cpx2 where it's used, removes cpx where it's not used anymore.

Supersedes #4506

pichlermarc avatar Feb 27 '24 13:02 pichlermarc

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.84%. Comparing base (e49c4c7) to head (5136509). Report is 9 commits behind head on main.

:exclamation: Current head 5136509 differs from pull request most recent head c3ba45d

Please upload reports for the commit c3ba45d to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4510      +/-   ##
==========================================
- Coverage   93.32%   92.84%   -0.49%     
==========================================
  Files          84      328     +244     
  Lines        1694     9481    +7787     
  Branches      349     2031    +1682     
==========================================
+ Hits         1581     8803    +7222     
- Misses        113      678     +565     

see 269 files with indirect coverage changes

codecov[bot] avatar Feb 27 '24 13:02 codecov[bot]

~~Keeping as draft as I'll have to try that out on windows.~~ Edit: started working after a branch update

pichlermarc avatar Feb 27 '24 16:02 pichlermarc

LGTM.

(It looks like cpx2 is only used as a test package for RequireInTheMiddleSingleton, so picking some other module, or manually creating a local module in a fixtures/ subdir and using that directly would work as well. However, using cpx2 seems fine.)

Yep, opened a follow-up issue: #4533

pichlermarc avatar Mar 08 '24 14:03 pichlermarc

Hmm, interestingly it failed on windows again. :thinking: converting back to draft.

pichlermarc avatar Mar 08 '24 14:03 pichlermarc

The windows failure was a timeout:

  RequireInTheMiddleSingleton
    register
      ✔ should return a hooked object
      core module
        AND module name matches
          ✔ should call `onRequire`
        AND module name does not match
          ✔ should not call `onRequire`
      core module with sub-path
        AND module name matches
          ✔ should call `onRequire`
      non-core module
        AND module name matches
          ✔ should call `onRequire` (2809ms)
      non-core module with sub-path
        AND module name matches
          1) should call `onRequire`

  instrumenting a scoped package
    ✔ should patch internal file and main module (122ms)
    ✔ should patch main module


  50 passing (6s)
  1 failing

  1) RequireInTheMiddleSingleton
       register
         non-core module with sub-path
           AND module name matches
             should call `onRequire`:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\a\opentelemetry-js\opentelemetry-js\experimental\packages\opentelemetry-instrumentation\test\node\RequireInTheMiddleSingleton.test.ts)
      at processImmediate (node:internal/timers:476:21)

I think mocha has a default timeout of 2s. Even running these tests locally on my dev macOS laptop, those particular test cases are slow:

  RequireInTheMiddleSingleton
    register
      ✔ should return a hooked object
      core module
        AND module name matches
          ✔ should call `onRequire`
        AND module name does not match
          ✔ should not call `onRequire`
      core module with sub-path
        AND module name matches
          ✔ should call `onRequire`
      non-core module
        AND module name matches
          ✔ should call `onRequire` (1043ms)
      non-core module with sub-path
        AND module name matches
          ✔ should call `onRequire` (582ms)

Also, interestingly, the preceding it('should call `onRequire`' test has an explicit timeout of 30s set. My guess is that was set originally to cope with a slow CI runner occasionally failing. So a suggestion would be to add a similar explicit longer timeout to avoid a flaky test:

diff --git a/experimental/packages/opentelemetry-instrumentation/test/node/RequireInTheMiddleSingleton.test.ts b/experimental/packages/opentelemetry-instrumentation/test/node/RequireInTheMiddleSingleton.test.ts
index 1ba41bd0..75cd0ad6 100644
--- a/experimental/packages/opentelemetry-instrumentation/test/node/RequireInTheMiddleSingleton.test.ts
+++ b/experimental/packages/opentelemetry-instrumentation/test/node/RequireInTheMiddleSingleton.test.ts
@@ -178,7 +178,7 @@ describe('RequireInTheMiddleSingleton', () => {
             modulePath,
             baseDir
           );
-        });
+        }).timeout(30000);
       });
     });
   });

trentm avatar Mar 09 '24 01:03 trentm

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar May 13 '24 06:05 github-actions[bot]

Also, interestingly, the preceding it('should call `onRequire`' test has an explicit timeout of 30s set. My guess is that was set originally to cope with a slow CI runner occasionally failing. So a suggestion would be to add a similar explicit longer timeout to avoid a flaky test.

yep that seems to work, marking it as ready-to-review again.

pichlermarc avatar May 27 '24 12:05 pichlermarc