supabase-community / sentry-integration-js

MIT License
10 stars 3 forks source link

TypeError: Cannot create proxy with a non-object as target or handler #7

Closed williamoverton closed 5 months ago

williamoverton commented 6 months ago

Bug report

Describe the bug

When fellowing the setup information from the readme like so:

import { SupabaseClient } from '@supabase/supabase-js';
import { SupabaseIntegration } from '@supabase/sentry-js-integration';

Sentry.init({
    dsn: '...',
    tracesSampleRate: 1.0,
    profilesSampleRate: 1.0,
    integrations: [
        nodeProfilingIntegration() as any,
        new SupabaseIntegration(SupabaseClient, {
            tracing: true,
            breadcrumbs: true,
            errors: true
        }) as any
    ]
});

I get the following error:

TypeError: Cannot create proxy with a non-object as target or handler
    at SupabaseIntegration.instrumentSupabaseClient (file:///projects/main-app/node_modules/@supabase/sentry-js-integration/index.js:188:37)
    at SupabaseIntegration.setupOnce (file:///projects/main-app/node_modules/@supabase/sentry-js-integration/index.js:165:10)
    at setupIntegration (/projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/integration.js:116:17)
    at /projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/integration.js:86:7
    at Array.forEach (<anonymous>)
    at Object.setupIntegrations (/projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/integration.js:83:16)
    at NodeClient._setupIntegrations (/projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/baseclient.js:424:38)
    at NodeClient.init (/projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/baseclient.js:272:12)
    at initializeClient (/projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/sdk.js:58:12)
    at Object.initAndBind (/projects/main-app/node_modules/@sentry/sveltekit/node_modules/@sentry/core/cjs/sdk.js:37:3)

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Use sveltekit and the @supabase/ssr package. and then add Sentry and this integration.

Expected behavior

Amazing supabase observability

Screenshots

N/A

System information

williamoverton commented 6 months ago

Possibly related:

when using sveltekit which uses vite as the bundler, I get this error when trying to import supabase-js:

Error when evaluating SSR module /src/hooks.server.ts: failed to import "@supabase/supabase-js"
|- SyntaxError: [vite] Named export 'SupabaseClient' not found. The requested module '@supabase/supabase-js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@supabase/supabase-js';
const {SupabaseClient} = pkg;

I followed that it said to do for my setup

kamilogorek commented 6 months ago

Hey, I see you're using 2.39.2, which is one of few patch releases that broke the integration 😅 I even had a note about this, but it got removed as the integration works with latest of 2.39+ - https://github.com/supabase-community/sentry-integration-js/commit/010a0a915b6755d36410d4a54a96435055b06d65

Update the package and you should be good to go :)

williamoverton commented 6 months ago

@kamilogorek I tried upgrading to the latest version of supabase-js but I still get the same error.

kamilogorek commented 6 months ago

I just tried example SvelteKit app with Sentry + our integration and it worked without any issues. Unless you're able to provide some reproduction, it'll be difficult for me to fix it.

t1mmen commented 4 months ago

I'm having a similar problem, unfortunately without a reproduction example, but noting anyway.

Dependencies of note:

sentry.server.config.ts initialization:

  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    tracesSampleRate: restrictSentry ? 0.5 : 1,
    profilesSampleRate: restrictSentry ? 0.5 : 1,
    integrations: [
      nodeProfilingIntegration(),
      new Sentry.Integrations.RequestData({
        include: {
          data: restrictSentry ? false : true,
        },
      }),
      new SupabaseIntegration(SupabaseClient, {
        tracing: true,
        breadcrumbs: true,
        errors: true,
      }),
    ],
    release: process.env.SENTRY_RELEASE,
    beforeSendTransaction: beforeSendTransaction,
    sendDefaultPii: false,
  });

CleanShot 2024-07-01 at 12 22 10

kamilogorek commented 4 months ago

@supabase/supabase-js@2.39.3

The same usecase as in the comment above: https://github.com/supabase-community/sentry-integration-js/issues/7#issuecomment-2048200150

Update the SDK and you'll be fine :)

t1mmen commented 4 months ago

@kamilogorek Doh! Sorry for adding noise to your day, thanks for helping me see that :)