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

Problem with attachments API (getAttachments) #5229

Closed
lforst opened this issue Jun 8, 2022 · 17 comments · Fixed by #6258
Closed

Problem with attachments API (getAttachments) #5229

lforst opened this issue Jun 8, 2022 · 17 comments · Fixed by #6258
Assignees

Comments

@lforst
Copy link
Member

lforst commented Jun 8, 2022

After upgrading sentry to v7 getting below error. I am using sentry with node express project

  message: 'finalScope.getAttachments is not a function or its return value is not iterable',
  code: undefined,
  sentry: '888a4d2d434b4e1c9b5dcea80eb99791',
  stack: 'TypeError: finalScope.getAttachments is not a function or its return value is not iterable\n' +
    '    at NodeClient._prepareEvent (/srv/server/node_modules/@sentry/core/cjs/baseclient.js:403:69)\n' +
    '    at NodeClient._prepareEvent (/srv/server/node_modules/@sentry/node/cjs/client.js:151:18)\n' +
    '    at NodeClient._processEvent (/srv/server/node_modules/@sentry/core/cjs/baseclient.js:598:17)\n' +
    '    at NodeClient._captureEvent (/srv/server/node_modules/@sentry/core/cjs/baseclient.js:554:17)\n' +
    '    at NodeClient.captureEvent (/srv/server/node_modules/@sentry/core/cjs/baseclient.js:147:12)\n' +
    '    at NodeClient.captureEvent (/srv/server/node_modules/@sentry/node/cjs/client.js:93:18)\n' +
    '    at Hub._invokeClient (/srv/server/node_modules/winston-sentry-log/node_modules/@sentry/hub/dist/hub.js:384:35)\n' +
    '    at Hub.captureEvent (/srv/server/node_modules/winston-sentry-log/node_modules/@sentry/hub/dist/hub.js:171:14)\n' +
    '    at Transaction.finish (/srv/server/node_modules/@sentry/tracing/cjs/transaction.js:142:22)\n' +
    '    at Immediate.<anonymous> (/srv/server/node_modules/@sentry/node/cjs/handlers.js:51:21)\n' +
    '    at processImmediate (internal/timers.js:464:21)\n' +
    '    at process.topLevelDomainCallback (domain.js:152:15)\n' +
    '    at process.callbackTrampoline (internal/async_hooks.js:128:24)'

Originally posted by @pnutmath in #5004 (comment)

@lforst
Copy link
Member Author

lforst commented Jun 8, 2022

@pnutmath Could you share what your setup looks like to get this error?

@pnutmath
Copy link

pnutmath commented Jun 8, 2022

One more point here is I am using winston-sentry-log package also to capture error level logs in sentry.

And setup I followed is exactly same as mentioned in guide: https://docs.sentry.io/platforms/node/guides/express/ along with sentry tracer.

I have downgraded sentry packages and it working fine as earlier.

    "@sentry/node": "^6.19.7",
    "@sentry/tracing": "^6.19.7",

@lforst
Copy link
Member Author

lforst commented Jun 8, 2022

Hi, winston-sentry-log seems to be using @sentry/node v6. For the SDK to work properly, all used versions need to be in sync. Please try your application without winston-sentry-log and report back whether that fixes the issue! If it does, I suggest you raise an issue in the winston-sentry-log repositor to update their dependency. If it doesn't we need to investigate further.

@fmorris2
Copy link

I was encountering this as well. Solved by downgrading as @pnutmath suggested above.

@marcus-sa
Copy link

I'm getting the same issue, but with React instead.
If I downgrade to 6.x.x, then https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/#react-router-v6 won't be available though.

@lforst
Copy link
Member Author

lforst commented Jun 24, 2022

Hi @fmorris2 @marcussa, obviously people having to downgrade the SDK is not what we want. We have a suspicion on the problem but to confirm, we would need a reproduction setup.

Also, just to make sure nothing fishy is going on with versions: Can you run yarn list --pattern sentry or npm ls | grep 'sentry' and share the output? Thanks!

@lforst lforst assigned lforst and unassigned lforst Jun 24, 2022
@timfish
Copy link
Collaborator

timfish commented Jun 24, 2022

make sure nothing fishy is going on

I'll take a look into this 😆

@timfish
Copy link
Collaborator

timfish commented Jun 24, 2022

Looking through the code and the stack trace at the top of this issue, I can't see a way to reproduce this if all the Sentry dependencies have been updated to v7. It looks like a v6 scope is getting passed through with getAttachments missing.

Also, just to make sure nothing fishy is going on with versions: Can you run yarn list --pattern sentry or npm ls | grep 'sentry' and share the output?

You can also check through your lock file for Sentry dependencies and ensure they're all v7.

Alternatively, linking to a basic app that reproduces this would help me figure out what's up.

@marcus-sa
Copy link

marcus-sa commented Jul 6, 2022

@timfish I've figured out what's causing the issue.
We have two repositories.
The app shell in our first repository is using Sentry v5, but all of our other apps in the second repository is using Sentry v7.
Essentially, what we do is load and instantiate the apps (webpack bundles served from an S3 bucket) in the app shell in our first repository.
Unfortunately, Sentry is polluting the global namespace, resulting in that we cannot instantiate multiple Sentry clients, or even Sentry clients with different versions.
It's not possible for us to use iframes.

@AbhiPrasad
Copy link
Member

We unfortunately do not support any use case where you are running different versions of a Sentry SDK instance in the same environment. You'll have to make everything is updated to v7!

Once that is done, check out our docs for using individual Sentry clients. This may help point you in the right direction for how to instantiate multiple Sentry clients.

@dzborowski
Copy link

@AbhiPrasad "We unfortunately do not support any use case where you are running different versions of a Sentry SDK instance in the same environment. You'll have to make everything is updated to v7!" can we load Sentry SDK two times on page with same version(I know is bad for web performance :<)? We got web page composed with 2 apps and we are control only one app. Are there any plans for future to allow such behaviour?

@lforst
Copy link
Member Author

lforst commented Aug 29, 2022

@dzborowski No, sadly this is a major limitation of the SDK right now. As soon as you introduce multiple versions of the SDK (especially multiple major versions) the SDK will almost always break in some capacity.

As for plans for the future: We currently have no short term plans to fix this.

@ScottFSeely
Copy link

@lforst @AbhiPrasad
Running into this issue after updating to v7. This is happening to a small user fragment who use certain extensions in the browser. It seems that if an extension is using an earlier version of sentry it completely cripples our app with this error.

We are going to rollback our version of sentry, and possibly look to remove its usage completely. It seems like a problem that will continue until these major versions are somewhat compatible (could at least handle errors like this).

@AbhiPrasad
Copy link
Member

@ScottFSeely you should be able to use beforeSend to filter this error out. See: https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-platformidentifier-namebefore-send-. Does that option work for you?

@ScottFSeely
Copy link

@ScottFSeely you should be able to use beforeSend to filter this error out. See: https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-platformidentifier-namebefore-send-. Does that option work for you?

From what I can tell the the beforeSend is executed after this error is hit in _prepareEvent. I think I would also need access to the scope in beforeSend to identify the error correctly.

@AbhiPrasad
Copy link
Member

From what I can tell the the beforeSend is executed after this error is hit in _prepareEvent

beforeSend is always called right before the event is sent to Sentry - it's the last part of the event processing pipeline, so we should be safe to use it here.

@ScottFSeely
Copy link

@AbhiPrasad
The JS error (same as above) crashes the application before anything can be sent to Sentry. For me,beforeSend is not executed before this error triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants