Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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
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