appsignal / appsignal-nodejs

🟩 AppSignal for Node.js
https://www.appsignal.com/nodejs/
MIT License
28 stars 9 forks source link

Cannot find module 'bullmq' #1062

Closed bseverac closed 2 months ago

bseverac commented 3 months ago

Hello,

After Bump @appsignal/nodejs from 3.4.4 to 3.4.5

I've got an error :

node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/instrumentation.d.ts:2:30 - error TS2307: Cannot find module 'bullmq' or its corresponding type declarations.

2 import type * as bullmq from "bullmq";
unflxw commented 3 months ago

Hi @bseverac,

Thank you for reporting this. Could you share your tsconfig.json file?

bseverac commented 3 months ago

Yes off course

  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "allowUnreachableCode": false,
    "noImplicitThis": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    "noUnusedParameters": true,
    "alwaysStrict": true,
    "strictFunctionTypes": true,
    "strict": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "paths": {
      "@core/*": ["src/core/*"],
      "@config/*": ["src/config/*"],
      "@database/*": ["src/database/*"],
      "@features/*": ["src/features/*"],
      "@infrastructure/*": ["src/infrastructure/*"],
      "@stubs/*": ["tests/stubs/*"],
      "@integration/*": ["tests/integration/*"],
      "@functional/*": ["tests/functional/*"],
      "@utils/*": ["tests/utils/*"],
      "@migration/*": ["db-migration/*"]
    }
  }
}
unflxw commented 3 months ago

Thank you @bseverac! Sorry to ask for more details, but I am unable to reproduce this issue. Could you share how you initialise AppSignal in your application?

bseverac commented 3 months ago
const { Appsignal } = require('@appsignal/nodejs');

new Appsignal({
  active: process.env['NODE_ENV'] === 'production',
  name: 'xxxx',
  pushApiKey: process.env['xxx'] ,
  environment: process.env['yyy'],
});
unflxw commented 3 months ago

Thank you.

I still can't figure out how to reproduce this. 🫠

Would it be possible for you to set up an example repository where the issue takes place that I can clone? I am testing this with different TypeScript versions and I can't reproduce it regardless.

unflxw commented 3 months ago

Hi again @bseverac,

While I still have not been able to reproduce it, I believe I have figured out the cause and potentially fixed the issue. Could you run npm update @appsignal/opentelemetry-instrumentation-bullmq and see if that fixes it for you?

(npm list @appsignal/opentelemetry-instrumentation-bullmq should show 0.7.1)

bseverac commented 3 months ago

I'm using yarn npm list @appsignal/opentelemetry-instrumentation-bullmq give me 0.7.0 but forcing @appsignal/opentelemetry-instrumentation-bullmq version to 0.7.1 does'nt change anything

The only way i found is to add bullmq into dependencies but i'm not using it don't like this way

unflxw commented 3 months ago

When using 0.7.1, it shouldn't be necessary for bullmq to be a dependency (as it is now an optional peer dependency) and it shouldn't give you the same error (the line where the error originally appeared doesn't exist anymore in 0.7.1!)

The equivalent for yarn would be yarn upgrade @appsignal/opentelemetry-instrumentation-bullmq@0.7.1. Install it, make sure yarn list --pattern @appsignal/opentelemetry-instrumentation-bullmq returns 0.7.1, then try it again (without manually installing bullmq)

If it still gives you an error when compiling, please let me know which error it is (it can't be the exact same error)

bseverac commented 2 months ago

Hello thanks you for the help

yarn info @appsignal/opentelemetry-instrumentation-bullmq
└─ @appsignal/opentelemetry-instrumentation-bullmq@npm:0.7.1
   ├─ Instances: 1
   ├─ Version: 0.7.1
   │ 
   └─ Dependencies
      ├─ @opentelemetry/api@npm:^1.3.0 → npm:1.9.0
      ├─ @opentelemetry/instrumentation@npm:^0.41.2 → npm:0.41.2
      ├─ @opentelemetry/semantic-conventions@npm:^1.25.0 → npm:1.25.0

And the error

 yarn build
node_modules/@appsignal/nodejs/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/instrumentation.d.ts:2:30 - error TS2307: Cannot find module 'bullmq' or its corresponding type declarations.

2 import type * as bullmq from "bullmq";
                               ~~~~~~~~

Found 1 error(s).
unflxw commented 2 months ago

Thank you! To be sure, could you run cat node_modules/@appsignal/nodejs/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/package.json | grep version and check the value?

bseverac commented 2 months ago

Yes it's weird

cat node_modules/@appsignal/nodejs/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/package.json | grep version
  "version": "0.7.0",

I've try to delete node_module and reinstall without changes

lockfile seen good

"@appsignal/opentelemetry-instrumentation-bullmq@npm:0.7.1":
  version: 0.7.1
  resolution: "@appsignal/opentelemetry-instrumentation-bullmq@npm:0.7.1"
  dependencies:
    "@opentelemetry/api": "npm:^1.3.0"
    "@opentelemetry/instrumentation": "npm:^0.34.0"
    "@opentelemetry/semantic-conventions": "npm:^1.25.0"
    flat: "npm:^5.0.2"
  peerDependencies:
    bullmq: ^2 || ^3 || ^4 || ^5
  peerDependenciesMeta:
    bullmq:
      optional: true
  checksum: 65dcb35d18fdfd093cef6ca3b9f88444611892f6efd4125bc7848fa86d5514cbb9377fd6251fcb907d557e8dcefb526d3afe1d97d64e7d2c3e5942771550e8b4
  languageName: node
  linkType: hard
unflxw commented 2 months ago

Right, there's the issue. I'm not sure why Yarn is deciding to put version 0.7.0 in there. Maybe delete the lockfile, or roll it back to before updating @appsignal/nodejs, then try again from there?

bseverac commented 2 months ago

A yes i've got two @appsignal/opentelemetry-instrumentation-bullmq in the lockfile and one was with 0.7.0 I've clean the lockfile and it's ok now

Thanks for the help 🙏