#__turbopack_context__.x is not a function

1 messages · Page 1 of 1 (latest)

oblique pollen
#

Updated the next packages to the latest and got this error

loud raptorBOT
#

Hi @oblique pollen. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

I'm sorry, but the knowledge sources provided do not contain any information about the specific error "turbopack_context.x is not a function" after updating Next.js packages. There are several reports of Turbopack-related errors after upgrading Next.js, such as module factory issues, problems with certain libraries, and incompatibilities with Turbopack, but none mention this exact error message.

If you can provide more context or a reproduction, it may help narrow down the issue. Otherwise, I recommend checking for open issues on the Next.js GitHub repository or trying to revert to a previous working version to isolate the cause.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@oblique pollen Kapa.ai is still learning and improving, please let me know how I did by reacting below.

oblique pollen
#

@loud raptor

loud raptorBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

Sorry @oblique pollen, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

oblique pollen
#

Error Type

Runtime TypeError

Error Message

turbopack_context.x is not a function

at __TURBOPACK__module__evaluation__ (app/helpers/information.ts:42:23)
at __TURBOPACK__module__evaluation__ (app/components/pageComponent.tsx:5:1)
at __TURBOPACK__module__evaluation__ (app/page.tsx:5:1)

Code Frame

40 | }
41 |

42 | export async function encryptData(data: string): Promise<string> {
| ^
43 | const publicKey = pki.publicKeyFromPem(process.env.publicKey!);
44 | const publicKeyPem = pki.publicKeyToPem(publicKey);
45 | const publicKeyEncrypt = pki.publicKeyFromPem(publicKeyPem);

Next.js version: 15.5.4 (Turbopack)

@loud raptor

loud raptorBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

I'm sorry, but the knowledge sources do not contain any information about the specific error message "turbopack_context.x is not a function" in relation to Next.js 15.5.4 with Turbopack, nor do they provide guidance on resolving this runtime TypeError in the context of your encryptData function.

There are several reports of Turbopack-related issues after upgrading Next.js, including problems with module resolution, imported functions becoming undefined, and incompatibilities with certain libraries, but none mention this exact error or provide a direct solution for it. If you are encountering this after a recent upgrade, it may be related to a regression or a bug in Turbopack, as similar issues have been reported and sometimes resolved by disabling certain optimizations or downgrading versions. For example, disabling scope hoisting with nextConfig.experimental.turbopackScopeHoisting = false has been suggested as a workaround for some Turbopack bugs, but it is not clear if this applies to your case Regression in Next.js 15.4.0-canary.105 causes Turbo production builds to crash in certain scenarios.

If possible, try:

  • Disabling Turbopack to see if the error persists.
  • Setting turbopackScopeHoisting = false in your Next.js config.
  • Reverting to a previous working version of Next.js.

If the issue continues, consider opening a new issue on the Next.js GitHub repository with a minimal reproduction, as this may be a new or untracked bug.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@oblique pollen Kapa.ai is still learning and improving, please let me know how I did by reacting below.

oblique pollen
#

@loud raptor it seems to not recognise bun modules

loud raptorBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

Based on the knowledge sources, Turbopack currently has issues recognizing and resolving Bun-specific modules (such as imports from "bun") in Next.js projects. This is a known limitation: direct imports like import { SQL } from 'bun' often result in errors such as "Module not found: Can't resolve 'bun'" when using Turbopack, even if Bun is properly installed and configured. This is because Turbopack does not handle Bun-specific APIs well, as it expects Node.js compatibility and does not natively support Bun's runtime or module resolution semantics Turbopack: Bun APIs don't work with next.

Workarounds:

  • Use the Bun global namespace: Instead of importing directly from "bun", use the global Bun object (e.g., const client = new Bun.SQL();). This bypasses the bundler's module resolution and works at runtime because Bun injects these APIs globally.
  • Patch third-party libraries: If a library imports from "bun" directly, you can use bun patch to rewrite those imports to use the global namespace (e.g., replace new SQL() with new Bun.SQL()Turbopack: Bun APIs don't work with next.
  • Disable Turbopack: Running Next.js without the --turbopack flag allows Bun APIs to work as expected, since Webpack does not have the same limitation.

Why does this happen?
Direct imports must be resolved by the bundler (Turbopack), which currently does not support Bun modules. The namespaced global (Bun.*) works because it is injected at runtime and not resolved by the bundler Turbopack: Bun APIs don't work with next.

#

Summary:
Turbopack does not currently recognize Bun modules. Use the Bun global namespace as a workaround, or avoid Turbopack if you need full Bun API support. This is a known limitation and may be addressed in future updates.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@oblique pollen Kapa.ai is still learning and improving, please let me know how I did by reacting below.

oblique pollen
#

@loud raptor during docker build it seems that nextjs is stuck on optmising docker build for production

loud raptorBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

There are known issues with Next.js builds getting stuck or taking an unusually long time during Docker builds, especially when using Bun as the runtime or in certain Next.js versions. For example, users have reported that starting with Next.js 14.0.5-canary.10, bun run build inside Docker never completes the "Creating an optimized production build ..." step. This issue does not occur when running locally or when using Node.js instead of Bun in Docker. The problem appears to be specific to the combination of Bun, Docker, and certain Next.js versions Next.js >=14.0.5-canary.10 breaks bun next build in Docker.

Additionally, there are reports of severe build performance regressions in Docker with newer Next.js versions (e.g., 15.2.4), where builds that previously took ~2 minutes now take 10+ minutes, with most of the time spent on compilation. This regression is tied to the Next.js version upgrade and seems to be specific to Docker environments, even when using proper cache mounting and the recommended "standalone" output option Next.js 15.2.4 Build Performance Regression in Docker Build on GIthub actions (7+ mins just to compile).

Summary of what is known:

  • The issue is reproducible with Bun and certain Next.js versions in Docker.
  • It does not occur with Node.js in Docker or with Bun outside Docker.
  • Upgrading Next.js can introduce severe build slowdowns in Docker, even with the same code and dependencies.

Workarounds:

  • Use Node.js instead of Bun for Docker builds if possible.
  • Consider downgrading to a previous Next.js version where the issue does not occur.
  • Monitor the Next.js GitHub issues for updates or fixes related to Docker and Bun build compatibility.
#

If you are using Bun, this is a known and unresolved issue as of the latest reports in the knowledge sources. If you are using Node.js and still experiencing the issue, it may be related to a performance regression in recent Next.js versions in Docker environments.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: