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(instr-perf-hooks): avoid 'prepare' npm script because that runs on 'npm install' #1955

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Feb 23, 2024

Having a prepare script in the monorepo means that it runs during 'npm ci' which can break if some needed deps for that script haven't yet been installed.

details

This is the same change that was part of #1771
From that PR's description:

s/prepare/prepublishOnly/g is to avoid running the compile step in packages before npm install for all packages has completed. It resulted in various build errors. Using prepublishOnly is recommended (https://docs.npmjs.com/cli/v10/using-npm/scripts#prepare-and-prepublish) and is what the core repo was already doing.

I hit a breakage in npm ci in a separate PR (#1938). A few of the checks started failing:

Screenshot 2024-02-23 at 11 44 43 AM

E.g.: https://github.com/open-telemetry/opentelemetry-js-contrib/actions/runs/8023208091/job/21919224572?pr=1938 shows that instrumentation-perf-hooks's prepare and compile scripts were running during npm ci:

npm ERR! > @opentelemetry/instrumentation-perf-hooks@0.1.0 compile
npm ERR! > tsc -p .
npm ERR! 
npm ERR! node_modules/@types/node/ts4.8/globals.d.ts:6:76 - error TS2307: Cannot find module 'undici-types' or its corresponding type declarations.
npm ERR! 
npm ERR! 6 type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
npm ERR!                                                                              ~~~~~~~~~~~~~~
npm ERR! 
...

I don't fully understand the type issue here. I think a contributing factor is that the instrumentation-perf-hooks package has a dependency on a newer version of @types/node than is used in all other packages in this repo:

...
plugins/node/opentelemetry-instrumentation-graphql/package.json
51:    "@types/node": "18.6.5",

plugins/node/instrumentation-perf-hooks/package.json
48:    "@types/node": "^20.11.2",

plugins/node/opentelemetry-instrumentation-redis/package.json
58:    "@types/node": "18.6.5",
...

@d4nyll Do you happen to know if the newer @types/node is required for the types used in instrumentation-perf-hooks?

…n 'npm install'

Having a prepare script in the monorepo means that it runs during 'npm ci'
which can break if some needed deps for that script haven't yet been
installed.
@trentm trentm self-assigned this Feb 23, 2024
@trentm trentm requested a review from a team February 23, 2024 19:50
@trentm
Copy link
Contributor Author

trentm commented Feb 23, 2024

I don't fully understand the type issue here. I think a contributing factor is that the instrumentation-perf-hooks package has a dependency on a newer version of @types/node than is used in all other packages in this repo:

Actually, I'm not sure the usage of a separate @types/node version is at all related to build failure for which I made this PR. So the question about the needed @types/node version is an unrelated question.

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Merging #1955 (02e2ac3) into main (882fb4b) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1955   +/-   ##
=======================================
  Coverage   91.04%   91.04%           
=======================================
  Files         147      147           
  Lines        7530     7530           
  Branches     1507     1507           
=======================================
  Hits         6856     6856           
  Misses        674      674           

trentm added a commit to trentm/opentelemetry-js-contrib that referenced this pull request Feb 23, 2024
@d4nyll
Copy link
Contributor

d4nyll commented Feb 23, 2024

I mostly copied files from existing packages for @opentelemetry/instrumentation-perf-hooks.

s/prepare/prepublishOnly/g

I think I must have copied an older version of another package that used prepare, there's no reason for prepare over prepublishOnly

@types/node

All of the dependencies in devDependencies (@types/mocha, nyc, etc.) can be aligned with the rest of the repo. I just didn't think it mattered. The only version that matters is the Node.js version specified in engines.

So this change LGTM.

@trentm
Copy link
Contributor Author

trentm commented Feb 26, 2024

All of the dependencies in devDependencies (@types/mocha, nyc, etc.) can be aligned with the rest of the repo. I just didn't think it mattered. The only version that matters is the Node.js version specified in engines.

Thanks. I'll merge this now, and leave aligning the versions to a separate PR.

@trentm trentm merged commit 4483a32 into open-telemetry:main Feb 26, 2024
15 checks passed
@trentm trentm deleted the tm-no-prepare-script branch February 26, 2024 07:51
@dyladan dyladan mentioned this pull request Feb 26, 2024
pichlermarc pushed a commit that referenced this pull request Feb 27, 2024
* chore: remove the non-publishing packages from the npm workspace

Because they cause difficulties with updating `@opentelemetry/*` dependencies.
This is "Option 3" from #1917

Refs: #1917

* undo #1917 option 1 work (adding non-publishing packages to release-please config) from #1928

* move express example (haven't adjusted build / docs yet)

* express example updates to get it working

* remove non-publishing packages from release-please manifest

* move koa example

* fix up the koa-example-related files

* move the mongodb/examples files to the top-level

* fixup the mongodb-example files

* move mysql-example files

* fixup the mysql-example files

* move redis-example files to top level examples/ dir

* fixup redis-example files

* update examples README to no longer suggest moving to instruemtnation package dirs

* regenerate package-lock.json to rm the '.../examples' dir entries

'npm install --package-lock-only' did not accomplish this.
This regen was necessary because those vestigial entries caused
surprising breakage in some 'npm install --no-save ...' commands
such as TAV is doing. It broke TAV tests with mongodb@4.17.1.

* compile:examples is no longer a thing

* fix for 'npm ci' failures imported from PR #1955

* regenerate package-lock.json

'undici-types', required by the version of @types/node used
by the new instrumentation-perf-hooks, was lost in the merge
from main.

* add some more test output information to try to help debug flaky test

* fix tweaks to the test

* undo the instr-perf-hooks test assert tweaks, leaving that to a separate PR
@trentm
Copy link
Contributor Author

trentm commented Feb 27, 2024

and leave aligning the versions to a separate PR.

Done in #1967, FYI.

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.

3 participants