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

@envelop/sentry fails subscriptions #1436

Open
Tracked by #1358
robertherber opened this issue Jun 29, 2022 · 3 comments
Open
Tracked by #1358

@envelop/sentry fails subscriptions #1436

robertherber opened this issue Jun 29, 2022 · 3 comments
Labels
kind/bug Something isn't working

Comments

@robertherber
Copy link

robertherber commented Jun 29, 2022

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used 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 --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.

@n1ru4l n1ru4l added the kind/bug Something isn't working label Jun 29, 2022
@alexanderniebuhr
Copy link

We have found the same, but without using subscriptions. We do use GraphQL Yoga.

@robertherber
Copy link
Author

We have found the same, but without using subscriptions. We do use GraphQL Yoga.

I'm also using GraphQL Yoga (made that clearer in the original post) although "plugged into" fastify. Are you using vanilla GraphQL Yoga and get the same consistently?

@alexanderniebuhr
Copy link

alexanderniebuhr commented Jul 19, 2022

We use vanilla GraphQL Yoga with the envelop plugin registered like so:

async function main() {
	const server = createServer({
		graphiql: process.env.NODE_ENV === 'development',
		endpoint: "/",
		schema,
		context: createContext,
		plugins: [
			useSentry({
				startTransaction: true,
				renameTransaction: false,
				trackResolvers: true,
				includeRawResult: true,
				includeResolverArgs: true,
				includeExecuteVariables: true,
				skip({operationName}) {
					if (operationName == "health") return true
					return false
				},
			})
		]
	})
	await server.start()
}

We need the same patch, even for a very simple query.

snake575 added a commit to raptorsystems/raptor-libs that referenced this issue Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants