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(nestjs): do not make SentryTraced() decorated functions async #12879

Merged
merged 3 commits into from
Jul 11, 2024
Merged

fix(nestjs): do not make SentryTraced() decorated functions async #12879

merged 3 commits into from
Jul 11, 2024

Conversation

GitSquared
Copy link
Contributor

@GitSquared GitSquared commented Jul 11, 2024

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

The SentryTraced() decorator in the @sentry/nestjs package (introduced in #12721) stealthily turns any decorated function asynchronous.

We experienced issues on a production Nest app due to this - it's a bit sneaky because the Typescript compiler doesn't understand (or check at all?) that the decorator changes the function signature.

There was a test written to check sync support, but since the tests are end-to-end and always go through a first layer of async functions, the returned Promise<> from the supposedly sync test function was just unwrapped later without any issues.

This PR:

  • Fixes the testSpanDecoratorSync to fail if the decorated test function is not sync
  • Fixes the decorator itself by returning the decorated function without always marking it with async

Thank you!

Copy link
Contributor

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you for fixing this!

@nicohrubec nicohrubec merged commit d304248 into getsentry:develop Jul 11, 2024
85 checks passed
mydea pushed a commit that referenced this pull request Jul 11, 2024
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #12879
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.

2 participants