From 0f6de8fe53658e8cb45ce785773fc9d0a08dd310 Mon Sep 17 00:00:00 2001 From: Wan <495709+wa0x6e@users.noreply.github.com> Date: Wed, 25 Oct 2023 22:21:59 +0700 Subject: [PATCH 1/3] fix: check for value before manipulation (#730) --- src/helpers/metrics.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/metrics.ts b/src/helpers/metrics.ts index 500a62d9..b3bbe00f 100644 --- a/src/helpers/metrics.ts +++ b/src/helpers/metrics.ts @@ -58,9 +58,13 @@ export default function initMetrics(app: Express) { if (query && operationName) { const definition = parse(query).definitions.find( // @ts-ignore - def => def.name.value === operationName + def => def.name?.value === operationName ); + if (!definition) { + return; + } + // @ts-ignore const types = definition.selectionSet.selections.map(sel => sel.name.value); From 8a7854c471042e0e97bb4c074233d612fea61b11 Mon Sep 17 00:00:00 2001 From: Wan <495709+wa0x6e@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:14:26 +0700 Subject: [PATCH 2/3] fix: skip logging graphQl Errors (#728) --- src/helpers/metrics.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/helpers/metrics.ts b/src/helpers/metrics.ts index b3bbe00f..f3f50897 100644 --- a/src/helpers/metrics.ts +++ b/src/helpers/metrics.ts @@ -1,7 +1,7 @@ import init, { client } from '@snapshot-labs/snapshot-metrics'; import { capture } from '@snapshot-labs/snapshot-sentry'; import { Express, type Request, type Response } from 'express'; -import { parse } from 'graphql'; +import { GraphQLError, parse } from 'graphql'; import { spacesMetadata } from './spaces'; import { strategies } from './strategies'; import db from './mysql'; @@ -75,7 +75,9 @@ export default function initMetrics(app: Express) { } } } catch (e: any) { - capture(e); + if (!(e instanceof GraphQLError)) { + capture(e); + } } }); } From 8c7127fa050a21b8b64e242de2b81c019ec836f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:25:39 +0400 Subject: [PATCH 3/3] chore(deps): bump @snapshot-labs/snapshot-sentry from 1.5.1 to 1.5.2 (#720) * chore(deps): bump @snapshot-labs/snapshot-sentry from 1.5.1 to 1.5.2 Bumps @snapshot-labs/snapshot-sentry from 1.5.1 to 1.5.2. --- updated-dependencies: - dependency-name: "@snapshot-labs/snapshot-sentry" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: set NODE_ENV for test env --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> --- package.json | 2 +- test/.env.test | 1 + yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9bc1ca58..aba620d4 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@graphql-tools/schema": "^10.0.0", "@snapshot-labs/keycard": "^0.4.0", "@snapshot-labs/snapshot-metrics": "^1.3.1", - "@snapshot-labs/snapshot-sentry": "^1.5.1", + "@snapshot-labs/snapshot-sentry": "^1.5.2", "@snapshot-labs/snapshot.js": "^0.7.8", "bluebird": "^3.7.2", "connection-string": "^1.0.1", diff --git a/test/.env.test b/test/.env.test index 3f4db322..7346081a 100644 --- a/test/.env.test +++ b/test/.env.test @@ -1,2 +1,3 @@ HUB_DATABASE_URL=mysql://root:root@127.0.0.1:3306/hub_test SEQ_DATABASE_URL=mysql://root:root@127.0.0.1:3306/hub_test +NODE_ENV=test diff --git a/yarn.lock b/yarn.lock index d736f55f..75e7478e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1315,10 +1315,10 @@ node-fetch "^2.7.0" prom-client "^14.2.0" -"@snapshot-labs/snapshot-sentry@^1.5.1": - version "1.5.1" - resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-sentry/-/snapshot-sentry-1.5.1.tgz#c4b5da87a97f760d9327743f7748783aaef14d9a" - integrity sha512-2xM72Xqypr73x6iWP5kr9fsNDeygmbiflTLhKeahT5yjjpFaSyS2razha+qxjo6w+0rIwNQXXYnlcrju24K2iA== +"@snapshot-labs/snapshot-sentry@^1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-sentry/-/snapshot-sentry-1.5.2.tgz#a8c48e6602e0f236ba582a6728381e542501fe2a" + integrity sha512-xDZKiXigmfBWimDQGQwh/1WoqcD2n23nQczjWe+ukkLSvqk3AMwWz0F2tnd/MLiiklSyHezfcAzsSVMxlZPsPA== dependencies: "@sentry/node" "^7.60.1"