Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Problem with apollographql using turbopack - Unexpected error processing request: TypeError: module.require is not a function #73779

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
dincerpece opened this issue Dec 11, 2024 · 4 comments
Labels
bug Issue was opened via the bug report template. Turbopack Related to Turbopack with Next.js.

Comments

@dincerpece
Copy link

Link to the code that reproduces this issue

https://github.com/dincerpece/nextjs15-1_turbo_apollographql_error

To Reproduce

When I start it with turbopack and open the page, an error occurs.

next dev --port 65000 --turbo

Current vs. Expected behavior

When I run "next dev --port 65000" without turbopack, the response comes as it should. However, when I add the --turbo flag and start it, an error occurs!

Error: Response not successful: Received status code 500
at resolveErrorDev (http://localhost:65000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js:3662:65)
at processFullStringRow (http://localhost:65000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js:3824:23)
at processFullBinaryRow (http://localhost:65000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js:3812:9)
at progress (http://localhost:65000/_next/static/chunks/node_modules_next_dist_compiled_107ce8._.js:3932:102)

nextjs_turbopack_apollographqlerror

nextjs_turbopack_apollographqlerror2

And the warning I mentioned earlier keeps popping up during build!
#72525
nextjs_turbopack_apollographqlerror3

When I run next dev --port 65000 without turbopack, the response comes as it should and works without any problems.
nextjs_apollographql1
nextjs_apollographql2

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32607
  Available CPU cores: 16
Binaries:
  Node: 23.4.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.1.0 // Latest available version is detected (15.1.0).
  eslint-config-next: 15.0.3
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

I am running it locally. I want to use my application with turbopack and get fast response. A powerful framework like apollographql needs to be supported by turbopack. @trevor-scheer, @martinnabhan

@dincerpece dincerpece added the bug Issue was opened via the bug report template. label Dec 11, 2024
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Dec 11, 2024
@IntusFacultas
Copy link

Running into the exact same problem with the following versions

"@apollo/client": "^3.12.4",
"@apollo/experimental-nextjs-app-support": "^0.11.7",
"@apollo/server": "^4.11.2",
"next": "15.1.5",

@IntusFacultas
Copy link

Ok reporting back, I managed to "fix" the problem temporarily by tracking down the issue.

In the package @apollo/utils.createhash the transpiled code looks like this

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createHash = void 0;
const utils_isnodelike_1 = require("@apollo/utils.isnodelike");
function createHash(kind) {
    if (utils_isnodelike_1.isNodeLike) {
        return module.require("crypto").createHash(kind);
    }
    return require("sha.js")(kind);
}
exports.createHash = createHash;
//# sourceMappingURL=index.js.map

If you change the module.require to require everything works fine.

Looks like the problem is fixed in @apollo/[email protected]. I'll report back once I try upgrading that.

@IntusFacultas
Copy link

Reporting back! Looks like bumping @apollo/server to 4.11.3 fixed it. Give that a shot. :)

@timneutkens
Copy link
Member

Closing this issue as there was no new comment after @IntusFacultas's comment saying to try the latest version 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants