graphql-hive / graphql-hive/envelop
@envelop/sentry fails subscriptions
- Dominant language
- No language data
- Stars
- 827
- Forks
- 132
- PR merge metrics
- No merged PRs in 30d
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used [patch-package](https://github.com/ds300/patch-package) to patch `@envelop/sentry@3.5.0` for the project I'm working on.
`Symbol('sentryTracing')` is undefined when using subscriptions with graphql-ws (together with fastify and yoga) and as such causes the subscription call itself to fail. Not sure if the package is meant to be used with subscriptions - but at least it shouldn't crash :)
Here is the diff that solved my problem:
```diff
diff --git a/node_modules/@envelop/sentry/cjs/index.js b/node_modules/@envelop/sentry/cjs/index.js
index 1cd1c34..24ffd45 100644
--- a/node_modules/@envelop/sentry/cjs/index.js
+++ b/node_modules/@envelop/sentry/cjs/index.js
@@ -36,6 +36,10 @@ const useSentry = (options = {}) => {
}
const onResolverCalled = trackResolvers
? ({ args: resolversArgs, info, context }) => {
+ if(!context[sentryTracingSymbol]){
+ console.warn('no sentryTracingSymbol present, skipping tracing')
+ return null
+ }
const { rootSpan, opName, operationType } = context[sentryTracingSymbol];
if (rootSpan) {
const { fieldName, returnType, parentType } = info;
```
This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with @envelop/sentry/cjs/index.js and useSentry’s onResolverCalled path while reproducing a subscription through graphql-ws. Done means subscriptions no longer fail when sentryTracing is absent, while existing resolver tracing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100