mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #3752 from MetaMask/sentry-error-fix
sentry - simplify all ethjs errors for better batching
This commit is contained in:
commit
76e83365ca
27
app/scripts/lib/extractEthjsErrorMessage.js
Normal file
27
app/scripts/lib/extractEthjsErrorMessage.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
|
||||||
|
const errorLabelPrefix = 'Error: '
|
||||||
|
|
||||||
|
module.exports = extractEthjsErrorMessage
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// ethjs-rpc provides overly verbose error messages
|
||||||
|
// if we detect this type of message, we extract the important part
|
||||||
|
// Below is an example input and output
|
||||||
|
//
|
||||||
|
// Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced
|
||||||
|
//
|
||||||
|
// Transaction Failed: replacement transaction underpriced
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
function extractEthjsErrorMessage(errorMessage) {
|
||||||
|
const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
|
||||||
|
if (isEthjsRpcError) {
|
||||||
|
const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
|
||||||
|
const originalError = payloadAndError.slice(payloadAndError.indexOf(errorLabelPrefix) + errorLabelPrefix.length)
|
||||||
|
return originalError
|
||||||
|
} else {
|
||||||
|
return errorMessage
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
|
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage')
|
||||||
const errorLabelPrefix = 'Error: '
|
|
||||||
|
|
||||||
module.exports = reportFailedTxToSentry
|
module.exports = reportFailedTxToSentry
|
||||||
|
|
||||||
@ -9,30 +8,9 @@ module.exports = reportFailedTxToSentry
|
|||||||
//
|
//
|
||||||
|
|
||||||
function reportFailedTxToSentry({ raven, txMeta }) {
|
function reportFailedTxToSentry({ raven, txMeta }) {
|
||||||
const errorMessage = extractErrorMessage(txMeta.err.message)
|
const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
|
||||||
raven.captureMessage(errorMessage, {
|
raven.captureMessage(errorMessage, {
|
||||||
// "extra" key is required by Sentry
|
// "extra" key is required by Sentry
|
||||||
extra: txMeta,
|
extra: txMeta,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// ethjs-rpc provides overly verbose error messages
|
|
||||||
// if we detect this type of message, we extract the important part
|
|
||||||
// Below is an example input and output
|
|
||||||
//
|
|
||||||
// Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced
|
|
||||||
//
|
|
||||||
// Transaction Failed: replacement transaction underpriced
|
|
||||||
//
|
|
||||||
|
|
||||||
function extractErrorMessage(errorMessage) {
|
|
||||||
const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
|
|
||||||
if (isEthjsRpcError) {
|
|
||||||
const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
|
|
||||||
const originalError = payloadAndError.slice(payloadAndError.indexOf(errorLabelPrefix) + errorLabelPrefix.length)
|
|
||||||
return `Transaction Failed: ${originalError}`
|
|
||||||
} else {
|
|
||||||
return `Transaction Failed: ${errorMessage}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const Raven = require('raven-js')
|
const Raven = require('raven-js')
|
||||||
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
|
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
|
||||||
|
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage')
|
||||||
const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
|
const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
|
||||||
const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
|
const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
|
||||||
|
|
||||||
@ -21,8 +22,12 @@ function setupRaven(opts) {
|
|||||||
const client = Raven.config(ravenTarget, {
|
const client = Raven.config(ravenTarget, {
|
||||||
release,
|
release,
|
||||||
transport: function(opts) {
|
transport: function(opts) {
|
||||||
// modify report urls
|
|
||||||
const report = opts.data
|
const report = opts.data
|
||||||
|
// simplify ethjs error messages
|
||||||
|
report.exception.values.forEach(item => {
|
||||||
|
item.value = extractEthjsErrorMessage(item.value)
|
||||||
|
})
|
||||||
|
// modify report urls
|
||||||
rewriteReportUrls(report)
|
rewriteReportUrls(report)
|
||||||
// make request normally
|
// make request normally
|
||||||
client._makeRequest(opts)
|
client._makeRequest(opts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user