getsentry / profiling-node

The code for this repo now lives in https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node
MIT License
29 stars 10 forks source link

Types don't work with latest sentry packages #136

Closed tmcw closed 1 year ago

tmcw commented 1 year ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

SDK Version

7.48.0

Link to Sentry event

No response

What environment is your node script running in?

This is a TS types issue

How is your code deployed and bundled?

With Remix

Steps to Reproduce

Install this set of packages:

    "@sentry/cli": "^2.17.2",
    "@sentry/integrations": "^7.48.0",
    "@sentry/node": "^7.48.0",
    "@sentry/profiling-node": "^0.3.0",
    "@sentry/remix": "^7.48.0",
    "@sentry/tracing": "^7.48.0",

Typecheck this code:

  Sentry.init({
    dsn: '…',
    integrations: [
      new ProfilingIntegration()
    ],
  });

Expected Result

This should typecheck

Actual Result

error TS2322: Type 'ProfilingIntegration' is not assignable to type 'Integration'.
  Types of property 'setupOnce' are incompatible.
    Types of parameters 'getCurrentHub' and 'getCurrentHub' are incompatible.
      Call signature return types 'Hub' and 'Hub' are incompatible.
        The types of 'bindClient' are incompatible between these types.
          Type '(client?: import("/Users/xxx/v/xxx/node_modules/@sentry/node/node_modules/@sentry/types/types/client").Client<import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/options").ClientOptions<import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/typ...' is not assignable to type '(client?: import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/client").Client<import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/options").ClientOptions<import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/transport").BaseTransportOptions>> | undefined) => void'.
            Types of parameters 'client' and 'client' are incompatible.
              Type 'import("/Users/xxx/v/xxx/node_modules/@sentry/types/types/client").Client<import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/options").ClientOptions<import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/transport").BaseTransportOptions>> | undefined' is not assignable to type 'import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/client").Client<import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/options").ClientOptions<import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/transpo...'.
                Type 'import("/Users/xxx/v/xxx/node_modules/@sentry/types/types/client").Client<import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/options").ClientOptions<import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/transport").BaseTransportOptions>>' is not assignable to type 'import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/client").Client<import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/options").ClientOptions<import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/transpo...'.
                  Types of property 'on' are incompatible.
                    Type '{ (hook: "startTransaction" | "finishTransaction", callback: (transaction: import("/Users/xxx/v/xxx/node_modules/@sentry/types/types/transaction").Transaction) => void): void; (hook: "beforeEnvelope", callback: (envelope: import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/envelope").Envelope) => v...' is not assignable to type '{ (hook: "startTransaction" | "finishTransaction", callback: (transaction: import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/transaction").Transaction) => void): void; (hook: "beforeEnvelope", callback: (envelope: import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_m...'.
                      Type '{ (hook: "startTransaction" | "finishTransaction", callback: (transaction: import("/Users/xxx/v/xxx/node_modules/@sentry/types/types/transaction").Transaction) => void): void; (hook: "beforeEnvelope", callback: (envelope: import("/Users/tmcw/v/val.town/node_modules/@sentry/types/types/envelope").Envelope) => v...' is not assignable to type '{ (hook: "startTransaction" | "finishTransaction", callback: (transaction: import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_modules/@sentry/types/types/transaction").Transaction) => void): void; (hook: "beforeEnvelope", callback: (envelope: import("/Users/tmcw/v/val.town/node_modules/@sentry/node/node_m...'.
                        Types of parameters 'hook' and 'hook' are incompatible.
                          Type '"createDsc"' is not assignable to type '"startTransaction" | "finishTransaction"'.

95       new ProfilingIntegration(),
         ~~~~~~~~~~~~~~~~~~~~~~~~~~
tmcw commented 1 year ago

False alarm - I had some transitive deps not updated.

ak-beam commented 1 year ago

@tmcw Which transitive deps do you need to update? Just encountered this error when upgrading 7.53.1 => 7.58.0. All of the deps are matching.

diff --git a/package-lock.json b/package-lock.json
index 45e3b338..401f473b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11895,47 +11895,47 @@
       }
     },
     "node_modules/@sentry-internal/tracing": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.53.1.tgz",
-      "integrity": "sha512-a4H4rvVdz0XDGgNfRqc7zg6rMt2P1P05xBmgfIfztYy94Vciw1QMdboNiT7einr8ra8wogdEaK4Pe2AzYAPBJQ==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.58.0.tgz",
+      "integrity": "sha512-7V/vkFFYCmSq25er3Y0wukkTM940Wvk9qjh7kWcCCeesKFHNGBCP7HVZhsymjPIJGGJTvRWc9MgBzRGe/c16Xg==",
       "dependencies": {
-        "@sentry/core": "7.53.1",
-        "@sentry/types": "7.53.1",
-        "@sentry/utils": "7.53.1",
-        "tslib": "^1.9.3"
+        "@sentry/core": "7.58.0",
+        "@sentry/types": "7.58.0",
+        "@sentry/utils": "7.58.0",
+        "tslib": "^2.4.1 || ^1.9.3"
       },
       "engines": {
         "node": ">=8"
       }
     },
     "node_modules/@sentry-internal/tracing/node_modules/@sentry/core": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.53.1.tgz",
-      "integrity": "sha512-DAH8IJNORJJ7kQLqsZuhMkN6cwJjXzFuuUoZor7IIDHIHjtl51W+2F3Stg3+I3ZoKDfJfUNKqhipk2WZjG0FBg==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.58.0.tgz",
+      "integrity": "sha512-tdz+HOh9blnfJ4ZSfsaVaSh/i7pD2QfmC0///fWlNm+IvD+SAgYFP6M3PIsJMsaN5heZ9XMNY4wnxvd+vvJwPQ==",
       "dependencies": {
-        "@sentry/types": "7.53.1",
-        "@sentry/utils": "7.53.1",
-        "tslib": "^1.9.3"
+        "@sentry/types": "7.58.0",
+        "@sentry/utils": "7.58.0",
+        "tslib": "^2.4.1 || ^1.9.3"
       },
       "engines": {
         "node": ">=8"
       }
     },
     "node_modules/@sentry-internal/tracing/node_modules/@sentry/types": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.53.1.tgz",
-      "integrity": "sha512-/ijchRIu+jz3+j/zY+7KRPfLSCY14fTx5xujjbOdmEKjmIHQmwPBdszcQm40uwofrR8taV4hbt5MFN+WnjCkCw==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.58.0.tgz",
+      "integrity": "sha512-uy8rww5R0WSxr9kB1R1BXWomkKXosK+jOFslbIda4CfTiAMEINi7rXkqTzPJKCIRLHFvKXDFUIkMCHNMkgYjwA==",
       "engines": {
         "node": ">=8"
       }
     },
     "node_modules/@sentry-internal/tracing/node_modules/@sentry/utils": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.53.1.tgz",
-      "integrity": "sha512-DKJA1LSUOEv4KOR828MzVuLh+drjeAgzyKgN063OEKmnirgjgRgNNS8wUgwpG0Tn2k6ANZGCwrdfzPeSBxshKg==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.58.0.tgz",
+      "integrity": "sha512-EAknRDovGBnIVvGLJVxPbB1gUY/VCUoVov26Fk1BYLtUmWlzt+JYHsBJptHw15onu+M0em7z7Iax4wKoiNhhzA==",
       "dependencies": {
-        "@sentry/types": "7.53.1",
-        "tslib": "^1.9.3"
+        "@sentry/types": "7.58.0",
+        "tslib": "^2.4.1 || ^1.9.3"
       },
       "engines": {
         "node": ">=8"
@@ -12068,51 +12068,51 @@
       }
     },
     "node_modules/@sentry/profiling-node/node_modules/@sentry/core": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.53.1.tgz",
-      "integrity": "sha512-DAH8IJNORJJ7kQLqsZuhMkN6cwJjXzFuuUoZor7IIDHIHjtl51W+2F3Stg3+I3ZoKDfJfUNKqhipk2WZjG0FBg==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.58.0.tgz",
+      "integrity": "sha512-tdz+HOh9blnfJ4ZSfsaVaSh/i7pD2QfmC0///fWlNm+IvD+SAgYFP6M3PIsJMsaN5heZ9XMNY4wnxvd+vvJwPQ==",
       "dependencies": {
-        "@sentry/types": "7.53.1",
-        "@sentry/utils": "7.53.1",
-        "tslib": "^1.9.3"
+        "@sentry/types": "7.58.0",
+        "@sentry/utils": "7.58.0",
+        "tslib": "^2.4.1 || ^1.9.3"
       },
       "engines": {
         "node": ">=8"
       }
     },
     "node_modules/@sentry/profiling-node/node_modules/@sentry/node": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.53.1.tgz",
-      "integrity": "sha512-B4ax8sRd54xj4ad+4eY2EOKNt0Mh1NjuLW1zUKS8HW3h0bmuaDFzGuhEVvEY5H4SaV6tZKj1c0dvnMnyUbYkhA==",
-      "dependencies": {
-        "@sentry-internal/tracing": "7.53.1",
-        "@sentry/core": "7.53.1",
-        "@sentry/types": "7.53.1",
-        "@sentry/utils": "7.53.1",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.58.0.tgz",
+      "integrity": "sha512-Br6l0XuBEI13dektlPi0jvaVrUEirL7Z61SvbdjR8C/G6O9TXw0wKwc/BXf1GYV5JP7jsWHdRQEO2s45mtmNwQ==",
+      "dependencies": {
+        "@sentry-internal/tracing": "7.58.0",
+        "@sentry/core": "7.58.0",
+        "@sentry/types": "7.58.0",
+        "@sentry/utils": "7.58.0",
         "cookie": "^0.4.1",
         "https-proxy-agent": "^5.0.0",
         "lru_map": "^0.3.3",
-        "tslib": "^1.9.3"
+        "tslib": "^2.4.1 || ^1.9.3"
       },
       "engines": {
         "node": ">=8"
       }
     },
     "node_modules/@sentry/profiling-node/node_modules/@sentry/types": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.53.1.tgz",
-      "integrity": "sha512-/ijchRIu+jz3+j/zY+7KRPfLSCY14fTx5xujjbOdmEKjmIHQmwPBdszcQm40uwofrR8taV4hbt5MFN+WnjCkCw==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.58.0.tgz",
+      "integrity": "sha512-uy8rww5R0WSxr9kB1R1BXWomkKXosK+jOFslbIda4CfTiAMEINi7rXkqTzPJKCIRLHFvKXDFUIkMCHNMkgYjwA==",
       "engines": {
         "node": ">=8"
       }
     },
     "node_modules/@sentry/profiling-node/node_modules/@sentry/utils": {
-      "version": "7.53.1",
-      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.53.1.tgz",
-      "integrity": "sha512-DKJA1LSUOEv4KOR828MzVuLh+drjeAgzyKgN063OEKmnirgjgRgNNS8wUgwpG0Tn2k6ANZGCwrdfzPeSBxshKg==",
+      "version": "7.58.0",
+      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.58.0.tgz",
+      "integrity": "sha512-EAknRDovGBnIVvGLJVxPbB1gUY/VCUoVov26Fk1BYLtUmWlzt+JYHsBJptHw15onu+M0em7z7Iax4wKoiNhhzA==",
       "dependencies": {
-        "@sentry/types": "7.53.1",
-        "tslib": "^1.9.3"
+        "@sentry/types": "7.58.0",
+        "tslib": "^2.4.1 || ^1.9.3"
       },
       "engines": {
         "node": ">=8"
ak-beam commented 1 year ago

Ultimately, reinstalling to resync all the transitive deps worked for me:

npm install @sentry/node@latest @sentry/profiling-node@latest