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

Next 13 Module build failed UnhandledSchemeError #8133

Closed
alikleit opened this issue May 16, 2023 · 21 comments · Fixed by #8142
Closed

Next 13 Module build failed UnhandledSchemeError #8133

alikleit opened this issue May 16, 2023 · 21 comments · Fixed by #8142
Assignees

Comments

@alikleit
Copy link

alikleit commented May 16, 2023

Environment

self-hosted (https://develop.sentry.dev/self-hosted/)

Steps to Reproduce

  1. npx create-next-app@latest
√ What is your project named? 
√ Would you like to use TypeScript with this project? Yes
√ Would you like to use ESLint with this project?  Yes
√ Would you like to use Tailwind CSS with this project?  No
√ Would you like to use `src/` directory with this project?  Yes
√ Use App Router (recommended)?  Yes
√ Would you like to customize the default import alias? Yes
√ What import alias would you like configured? ... @/*
  1. npx @sentry/wizard@latest -i nextjs
  2. pnpm build

Expected Result

Build should be successfull

Actual Result

Failed to compile.

C:Users<name><path-to-project>sentry.server.config.ts
Module build failed: UnhandledSchemeError: Reading from "C:Users<name><path-to-project>sentry.server.config.ts" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "c:" URIs.

dependencies

    "@sentry/nextjs": "^7.52.1",
    "@types/node": "20.1.5",
    "@types/react": "18.2.6",
    "@types/react-dom": "18.2.4",
    "eslint": "8.40.0",
    "eslint-config-next": "13.4.2",
    "next": "13.4.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "typescript": "5.0.4"

Product Area

Issues

Link

No response

DSN

No response

Version

No response

@getsantry
Copy link

getsantry bot commented May 16, 2023

Assigning to @getsentry/support for routing, due by Tuesday, May 16th at 5:00 pm (sfo). ⏲️

@AbhiPrasad AbhiPrasad transferred this issue from getsentry/sentry May 16, 2023
@AbhiPrasad
Copy link
Member

Hey @alikleit, thanks for writing in! Are you running this on windows?

If you run git status after you've run npx @sentry/wizard@latest -i nextjs, what gets emitted?

Also, after you've run npx @sentry/wizard@latest -i nextjs, could you share the logs that get generated? Something that looks like so:

◇  Installed @sentry/nextjs with npm.
│
◆  Created fresh sentry.server.config.ts.
│
◆  Created fresh sentry.client.config.ts.
│
◆  Created fresh sentry.edge.config.ts.
│
◆  Added Sentry configuration to next.config.js. (you probably want to clean this up a bit!)
│
◆  Created pages/sentry-example-page.js.
│
◆  Created pages/api/sentry-example-api.js.
│
◆  Created .sentryclirc with auth token.
│
◆  Added .sentryclirc to .gitignore.

@AbhiPrasad
Copy link
Member

Ah what also might be a thing is that we need to detect if an src directory is being used and put our example project in there instead of using top level pages.

@alikleit
Copy link
Author

alikleit commented May 16, 2023

Hey @AbhiPrasad!

I'm running on windows, there's no git on the test project which I composed to make sure it's not a third party package on the actual project that is causing that issue.

Same error with manual setup..

However, this is the log from the wizard:

o  Login complete.
|
o  Select your Sentry project.
|
o  Installed @sentry/nextjs with npm.
|
*  Created fresh sentry.server.config.ts.
|
*  Created fresh sentry.client.config.ts.
|
*  Created fresh sentry.edge.config.ts.
|
*  Added Sentry configuration to next.config.js. (you probably want to clean this up a bit!)
|
*  Created pages\sentry-example-page.js.
|
*  Created pages\api\sentry-example-api.js.
|
*  Created .sentryclirc with auth token.
|
*  Added .sentryclirc to .gitignore.

@joaomlap
Copy link

joaomlap commented May 16, 2023

Just want to say I have the exactly the same error which I had raised in StackOverflow:
https://stackoverflow.com/questions/76237075/sentry-next-js-13-4-webpack-supports-data-and-file-uris-by-default-you

@lforst
Copy link
Member

lforst commented May 16, 2023

Hm, I think a somewhat recent change introduced this bug. Lemme check.

@timfish
Copy link
Collaborator

timfish commented May 16, 2023

Confirmed this on Windows. I'll check the potential fix!

@lforst
Copy link
Member

lforst commented May 16, 2023

Thanks @timfish!

@timfish
Copy link
Collaborator

timfish commented May 16, 2023

That PR doesn't appear to fix it.

Here is the full error. I guess the paths aren't displayed correctly in this error because the back slash is an escape character!

> next-sentry-app@0.1.0 build
> next build

(node:22328) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Failed to compile.

C:Users imDocumentsRepositoriesext-sentry-appsentry.server.config.ts
Module build failed: UnhandledSchemeError: Reading from "C:Users        imDocumentsRepositoriesext-sentry-appsentry.server.config.ts" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "c:" URIs.
    at C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:395974
    at Hook.eval [as callAsync] (eval at create (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:13:28771), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:13:25925)
    at Object.processResource (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:395899)
    at processResource (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\loader-runner\LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\loader-runner\LoaderRunner.js:1:4667)
    at runLoaders (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\loader-runner\LoaderRunner.js:1:8590)
    at NormalModule._doBuild (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:395761)
    at NormalModule.build (C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:397789)
    at C:\Users\tim\Documents\Repositories\next-sentry-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:81243

Import trace for requested module:
C:Users imDocumentsRepositoriesext-sentry-appsentry.server.config.ts
./src/app/page.tsx


> Build failed because of webpack errors

@lforst
Copy link
Member

lforst commented May 16, 2023

@timfish could you check out the latest commit and share the logs of the build before it crashes if you find the time? Thank you!

@timfish
Copy link
Collaborator

timfish commented May 16, 2023

Here is the output:

TEST LOG {                                                                                                    
  sentryConfigFilePath: 'C:\\Users\\tim\\Documents\\Repositories\\next-sentry-app\\sentry.server.config.ts',  
  rp: 'C:\\Users\\tim\\Documents\\Repositories\\next-sentry-app\\src\\app\\layout.tsx',                       
  imp: '..\\..\\..\\sentry.server.config.ts'                                                                  
}                                                                                                             
TEST LOG {                                                                                                    
  sentryConfigFilePath: 'C:\\Users\\tim\\Documents\\Repositories\\next-sentry-app\\sentry.server.config.ts',  
  rp: 'C:\\Users\\tim\\Documents\\Repositories\\next-sentry-app\\src\\app\\page.tsx',                         
  imp: '..\\..\\..\\sentry.server.config.ts'                                                                  
}                                                                                                             

After the error we see:

Import trace for requested module:
C:Users imDocumentsRepositoriesext-sentry-appsentry.server.config.ts
./src/app/page.tsx

./src/app/layout.tsx
Module not found: Can't resolve '......sentry.server.config.ts'

https://nextjs.org/docs/messages/module-not-found

./src/app/page.tsx
Module not found: Can't resolve '......sentry.server.config.ts'

https://nextjs.org/docs/messages/module-not-found

So it looks like there are two issues:

  • .replace(/\\/g, '/') so we only have url valid slashes
  • path.dirname(resourcePath) so the path is relative to the directory

Like:

templateCode = `import "${path.relative(path.dirname(this.resourcePath), sentryConfigFilePath).replace(/\\/g, '/')}";\n`.concat(templateCode);

@timfish
Copy link
Collaborator

timfish commented May 16, 2023

Due to the incremental builds I spent forever trying to work out why I was not getting any console output after the first initial build!

I don't mind submitting a PR but wasn't sure if this was correct. Would you want to just exclude the import entirely if it isn't an absolute path?

    if (sentryConfigFilePath && path.isAbsolute(this.resourcePath)) {

@rortan134
Copy link

rortan134 commented Aug 22, 2023

Still getting this error on Next 13.4.19 Windows 10

Build failed: UnhandledSchemeError: Reading from "C:UsersDocumentsprojectnode_modules@sentryextjscjsconfig        emplatesequestAsyncStorageShim.js" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "c:" URIs.

@lforst
Copy link
Member

lforst commented Aug 23, 2023

@rortan134 what SDK version are you on?

@rortan134
Copy link

@rortan134 what SDK version are you on?

I am on ^7.64.0

@lforst
Copy link
Member

lforst commented Aug 28, 2023

@rortan134 opened a PR to fix: #8875

@rortan134
Copy link

rortan134 commented Sep 5, 2023

@rortan134 opened a PR to fix: #8875

Hey @lforst, I just tested the release (7.66.0) and now it seems to load but I'm getting the following warning on console:

warn - The Sentry SDK could not access the RequestAsyncStorage module. Certain features may not work. There is nothing you can do to fix this yourself, but future SDK updates may resolve this.

@lforst
Copy link
Member

lforst commented Sep 5, 2023

@rortan134 Do you have some kind of unconventional node_modules structure? Can you try purging your dependencies and reinstalling them?

@rortan134
Copy link

@rortan134 Do you have some kind of unconventional node_modules structure? Can you try purging your dependencies and reinstalling them?

I'm using npm workspaces, is it not compatible? Just did a fresh install and same thing 😪

@lforst
Copy link
Member

lforst commented Sep 5, 2023

@rortan134 I don't know what might cause this. Can you share a small reproduction example we could use to debug this further? Thanks!

@rortan134
Copy link

Seems like #8977 found the reason

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