Skip to content

Commit

Permalink
fix: handle empty array to PG. fixup error handling (#10133)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick committed Aug 16, 2024
1 parent 0bc5d76 commit ae28cde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
6 changes: 3 additions & 3 deletions packages/server/graphql/executeGraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import tracer from 'dd-trace'
import {graphql} from 'graphql'
import {FormattedExecutionResult} from 'graphql/execution/execute'
import type {GQLRequest} from '../types/custom'
import sendToSentry from '../utils/sendToSentry'
import CompiledQueryCache from './CompiledQueryCache'
import getDataLoader from './getDataLoader'
import getRateLimiter from './getRateLimiter'
Expand Down Expand Up @@ -59,10 +60,9 @@ const executeGraphQL = async (req: GQLRequest) => {
response = {errors: [new Error(message)] as any}
}
}
if (!__PRODUCTION__ && response.errors) {
if (response.errors) {
const [firstError] = response.errors
console.log((firstError as Error).stack)
console.trace({error: JSON.stringify(response)})
sendToSentry(firstError as Error)
}
dataLoader.dispose()
return response
Expand Down
6 changes: 0 additions & 6 deletions packages/server/graphql/handleGraphQLTrebuchetRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ const handleGraphQLTrebuchetRequest = async (
ip,
carrier
})
if (result.errors?.[0]) {
const [firstError] = result.errors
const safeError = new Error(firstError.message)
safeError.stack = firstError.stack
sendToSentry(safeError)
}
const safeResult = sanitizeGraphQLErrors(result)
// TODO if multiple results, send GQL_DATA for all but the last
const messageType = result.data ? 'complete' : 'error'
Expand Down
11 changes: 6 additions & 5 deletions packages/server/graphql/public/mutations/startCheckIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ const startCheckIn: MutationResolvers['startCheckIn'] = async (
.run(),
updateTeamByTeamId(updates, teamId),
r.table('AgendaItem').getAll(r.args(agendaItemIds)).update({meetingId}).run(),
getKysely()
.updateTable('AgendaItem')
.set({meetingId})
.where('id', 'in', agendaItemIds)
.execute()
agendaItemIds.length &&
getKysely()
.updateTable('AgendaItem')
.set({meetingId})
.where('id', 'in', agendaItemIds)
.execute()
])
IntegrationNotifier.startMeeting(dataLoader, meetingId, teamId)
analytics.meetingStarted(viewer, meeting)
Expand Down
7 changes: 1 addition & 6 deletions packages/server/utils/sendToSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ export interface SentryOptions {

// Even though this is a promise we'll never need to await it, so we'll never need to worry about catching an error
const sendToSentry = async (error: Error, options: SentryOptions = {}) => {
console.trace(
'SEND TO SENTRY',
error.message || error?.toString() || JSON.stringify(error),
JSON.stringify(options.tags),
JSON.stringify(options.extras)
)
console.log('SEND TO SENTRY', error || JSON.stringify(error))
const {sampleRate, tags, extras, userId, ip} = options
if (sampleRate && Math.random() > sampleRate) return
const fullUser = userId ? await getUserById(userId) : null
Expand Down

0 comments on commit ae28cde

Please sign in to comment.