Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
meilechwieder opened this issue Dec 14, 2022 · 4 comments
Open

Comments

@meilechwieder
Copy link

meilechwieder commented Dec 14, 2022

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

@JohnMichael746
Copy link

Hi, Meilechwieder.
What is the source code?

@JohnMichael746
Copy link

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)"}]

@meilechwieder
Copy link
Author

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 });
  }

@JohnMichael746
Copy link

JohnMichael746 commented Dec 14, 2022

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');  
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants