Skip to content

Build fails since proxyLoader parses non-Sentry JSON file #6012

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

Closed
3 tasks done
stefan-girlich opened this issue Oct 21, 2022 · 3 comments · Fixed by #6013
Closed
3 tasks done

Build fails since proxyLoader parses non-Sentry JSON file #6012

stefan-girlich opened this issue Oct 21, 2022 · 3 comments · Fixed by #6013
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@stefan-girlich
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.16.0

Framework Version

7.16.0

Link to Sentry event

No response

Steps to Reproduce

  1. install via "getting started" guide
  2. install @sentry/integrations:7.1.6.0, apply CaptureConsoleIntegration in both sentry.client.config.js and sentry.server.config.js
  3. extract sentry.base.config.js from the two config files and import the new file - this is done since both files are fully identical (and probably irrelevant in the context of this bug report)
  4. run yarn build (which delegates to next build)

Expected Result

  • build succeeds
  • non-sentry JSON files are not processed by sentry during the build phase

Actual Result

build error

proxyLoader.jsfails to process a JSON file place in pages/. excerpt from the log:

./src/pages/badges/create/stepNames.json
Module parse failed: Unexpected token "i" (0x69) in JSON at position 0 while parsing near "import * as stepName..."
File was processed with these loaders:
 * ./node_modules/@sentry/nextjs/cjs/config/loaders/proxyLoader.js
You may need an additional loader to handle the result of these loaders.
JSONParseError: Unexpected token "i" (0x69) in JSON at position 0 while parsing near "import * as stepName..."
    at JsonParser.parse (myproject/node_modules/next/dist/compiled/webpack/bundle5.js:105017:7)

workaround

place JSON file in custom directory src/config

full log: 20221021_build.log

@lforst
Copy link
Contributor

lforst commented Oct 21, 2022

Hi, thanks for reporting this! I tried reproducing this by putting a .json file in the pages directory and importing it from within a page - sadly that did not produce the error you shared. Are you using additional plugins that somehow process JSON files?

@lforst lforst added Status: Needs Reproduction Package: nextjs Issues related to the Sentry Nextjs SDK and removed Status: Untriaged labels Oct 21, 2022
@lforst
Copy link
Contributor

lforst commented Oct 21, 2022

Actually, nevermind. I might have figured out what the problem is. I think we're matching whatever.js which happens to be a substring of whatever.json 🤦

Lemme try and fix this.

@stefan-girlich
Copy link
Author

thanks a lot for the quick reaction and concise feedback! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants