stacktracejs/stacktrace.js

How can I see original functions names/files names with Nexj.js

meilechwieder opened this issue · 4 comments

I'm using StackTracer.fromError(errror) in production, and I'm getting an array like this:

[{"columnNumber":2978,"lineNumber":1,"fileName":"https://.../_next/static/chunks/pages/dashboard/documents-40dfae09f9854c91.js","functionName":"n.default","source":" at n.default (https://.../_next/static/chunks/pages/dashboard/documents-40dfae09f9854c91.js:1:2978)"}]

It does not give me the unminified function names/file names.

Expected Behavior

get the exact location in the source code that generated this bug

Current Behavior

compolied/minified function names like n.default, and sourcemap filename

Steps to Reproduce (for bugs)

I built the app with next.js but used a static export so it's a regular react app, I put the StackTrace in ErrorBoundary

Hi, Meilechwieder.
What is the source code?

I think this value should be end with ]
[{"columnNumber":2978,"lineNumber":1,"fileName":"https://.../_next/static/chunks/pages/dashboard/documents-40dfae09f9854c91.js","functionName":"n.default","source":" at n.default (https://.../_next/static/chunks/pages/dashboard/documents-40dfae09f9854c91.js:1:2978)"}]

Hi, Meilechwieder. What is the source code?

  componentDidCatch(error, errorInfo) {
    StackTrace.fromError(error).then(err=>{
      api.post("/report-frontend-error", { message: error.message, longMessage: JSON.stringify(err), url: document.URL });
    })
      console.log({ error, errorInfo });
  }

Please try this.

change longMessage: JSON.stringify(err)
into
longMessage: callback(err)

const callback = function(error) {
    return error.map(function(sf) {
        return sf.toString();
    }).join('\n');  
};