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!