diff --git a/server/src/routes/rootRouter.js b/server/src/routes/rootRouter.js index abc1ddc5f..4cafdaac2 100644 --- a/server/src/routes/rootRouter.js +++ b/server/src/routes/rootRouter.js @@ -1,6 +1,6 @@ const express = require('express') const fs = require('fs') -const { resolve } = require('path') +const { resolve, join } = require('path') const { SourceMapConsumer } = require('source-map') const config = require('@rm/config') const { log, HELPERS } = require('@rm/logger') @@ -52,14 +52,14 @@ rootRouter.post('/api/error/client', async (req, res) => { ? await Promise.all( stack.split('\n').map(async (stackLine, i) => { const match = stackLine.match( - /at (.+) \(https?:\/\/([^/]+)\/(.+\.js):(\d+):(\d+)\)/, + /at (.+) \((\/.+\.js):(\d+):(\d+)\)/, ) log.debug(HELPERS.client, { match, stackLine }) if (match) { - const [full, functionName, host, file, line, column] = match + const [full, functionName, file, line, column] = match const foundStack = await SourceMapConsumer.with( await fs.promises.readFile( - resolve(__dirname, '../../../dist', `${file}.map`), + join(__dirname, '../../../dist', `${file}.map`), 'utf8', ), null, @@ -81,7 +81,6 @@ rootRouter.post('/api/error/client', async (req, res) => { log.warn(HELPERS.client, 'Unable to find source map', { full, functionName, - host, file, line, column, diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx index 4457c6603..014a7e8ae 100644 --- a/src/components/ErrorBoundary.jsx +++ b/src/components/ErrorBoundary.jsx @@ -48,7 +48,10 @@ class ErrorBoundary extends React.Component { await Fetch.sendError({ cause: error.cause, message: error.message, - stack: error?.stack, + stack: error?.stack?.replace( + /(http|https):\/\/[a-z0-9.]+(:[0-9]+)?/g, + '', + ), name: error.name, uuid: this.state.uuid, })