Skip to content

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

Description

@meilechwieder

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

Activity

  1. zrsm commented on Dec 14, 2022

    @zrsm

    Hi, Meilechwieder.
    What is the source code?

  2. zrsm commented on Dec 14, 2022

    @zrsm

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

  3. meilechwieder commented on Dec 14, 2022

    @meilechwieder
    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 });
      }
    
  4. zrsm commented on Dec 14, 2022

    @zrsm

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions