3import * as _ from 'lodash-es' 13export const getErrHash = (errStr: string) => { 15 return calcReqHash(errStr + nonce, 'sha1').slice(0, errHashLen) 18const getSilencedMsgName = ({err, errStr}: {err: any, errStr: string}) => { 20 if (_.startsWith(errStr, 'quieterr')) { 25 if (_.endsWith(message, ' - Connection terminated unexpectedly')) { 26 return 'connectionTerminatedUnexpectedly' 29 "Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?", 30 'The operation is insecure.', 31 `Variable "$gqUserTok" of required type "String!" was not provided.`, 32 `Variable "$gpAuthEmail" of required type "ID!" was not provided.`, 33 `Variable "$gpUserOtpToken" of required type "String!" was not provided.`, 34 `Failed to read the 'localStorage' property from 'Window': Access is denied for this document` // untested 36 const idx = _.indexOf(errA, message) 41const seenSilencedErrs = new Set() 43export const getClientErrH = ({err}: {err: any}) => { 45 const {isPublicVis, code} = err.extensions || {} 48 const debugMsg = getErrStr({err, prettyHumanIncompleteHash: true}) 49 const classErrStr = getErrStr({err, forClassHash: true}) 51 const errHash = getErrHash(classErrStr + deploymentName) 53 const silencedMsgName = getSilencedMsgName({err, errStr}) 55 const stdoutError = !(isDevPc && code == jsErrSym) // noisy for dev at least 58 code == 'GRAPHQL_VALIDATION_FAILED' || code == 'GRAPHQL_PARSE_FAILED' 61 message: genericServerErr, 62 errHash: badGqlErrCode, // overwrite errHash so not spammed with million emails but still alerts 63 emailNotif: 'isquiet', 64 debugMsg, stdoutError, 71 message, errHash, emailNotif: dumpDebugH?.emailNotif, 72 debugMsg, stdoutError, isPublicVis, 76 if (silencedMsgName) { 77 const alreadySeen = seenSilencedErrs.has(silencedMsgName) 78 if (!alreadySeen) seenSilencedErrs.add(silencedMsgName) 79 return {message: genericServerErr, stdoutError: !alreadySeen, emailNotif: false} 82 if (code == 'BAD_USER_INPUT') { 84 message: isDevPc ? debugMsg : genericServerErr, 85 emailNotif: false, // for like: 620db463 Variable "$gqUserTok" of required type "String!" was not provided. 86 debugMsg, stdoutError: false, 91 message: errHash, errHash, emailNotif: true, 92 debugMsg, stdoutError,