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

Have an option to turn off function name inference get() request #65

Open
dko-slapdash opened this issue Jul 16, 2020 · 1 comment
Open

Comments

@dko-slapdash
Copy link

The problem: often times file names in the source map are artificial, e.g. webpack://[name]/packages/client/src/layout/ModalPageLayout.tsx. If the source map contains only line/column numbers and not the source code per se, then stacktrace-gps runs a separate XHR request to fetch such artificial files and of course fails. (Even if filenames are not artificial, it's unlikely that anyone will have source code files in production at all.)

A solution could be to have an option to turn off function name resolution if this resolution implies a network request. It sounds similar to offline:true, but it's actually not: with offline:true, even the *.map file won't be fetched, whilst for this particular issue, we need to fetch *.map and not to fetch individual source files.

I have a work-around for this though, but it's ugly:

const stackFrames = await StackTrace.fromError(error, {
  // StackTract d.ts file is stale, it doesn't include ajax() hook
  // supported by stacktrace-gps library, but we can use it actually.
  ajax: async (location: string, opts: any) =>
    location.startsWith("webpack://")
      ? ""
      : fetch(location, opts).then(async (res) =>
          res.status === 200 ? res.text() : ""
        ),
} as any);
@MetaSam
Copy link

MetaSam commented Oct 20, 2020

Thanks for the workaround, ugly but it works!

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