[GH-ISSUE #982] [webpack.cache.PackFileCacheStrategy] Serializing big strings (107kiB) warnings in Next.js #17163

Closed
opened 2026-04-15 15:08:49 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @daveycodez on GitHub (Dec 21, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/982

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Turn off --turbo in npm run dev

The console seems to be getting spammed with the following:

<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (223kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (103kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (107kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)

I'm not 100% sure where this is coming from but it is a minimal project with shadcn. I did however run @next/bundle-analyzer and better-auth is ticking in at around 949kb which is the largest module out of all of them. drizzle-orm is around 213kb, @neondatabase/serverless around 139kb

Maybe I could be wrong and better-auth isn't the culprit but from the bundle analyzer it is the largest atm

Current vs. Expected behavior

No console warnings

What version of Better Auth are you using?

1.0.22

Provide environment information

Next.js Pages Router

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

Backend

Auth config (if applicable)

No response

Additional context

No response

Originally created by @daveycodez on GitHub (Dec 21, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/982 ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce Turn off --turbo in npm run dev The console seems to be getting spammed with the following: ```shell <w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (223kiB) impacts deserialization performance (consider using Buffer instead and decode when needed) <w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (103kiB) impacts deserialization performance (consider using Buffer instead and decode when needed) <w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (107kiB) impacts deserialization performance (consider using Buffer instead and decode when needed) ``` I'm not 100% sure where this is coming from but it is a minimal project with shadcn. I did however run @next/bundle-analyzer and better-auth is ticking in at around 949kb which is the largest module out of all of them. drizzle-orm is around 213kb, @neondatabase/serverless around 139kb Maybe I could be wrong and better-auth isn't the culprit but from the bundle analyzer it is the largest atm ### Current vs. Expected behavior No console warnings ### What version of Better Auth are you using? 1.0.22 ### Provide environment information ```bash Next.js Pages Router ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) _No response_ ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 15:08:50 -05:00
Author
Owner

@Bekacru commented on GitHub (Dec 21, 2024):

Could you try adding this to your next config for your use case

experimental: {
  optimizePackageImports: ["better-auth"]
}

Regarding the bundle size:

  • First, this is server-side, so it shouldn't be a major concern. The client bundle should remain very small.
  • We ship Kysely with Better Auth, which accounts for at least a quarter of the bundle size.
  • To enable better tree-shaking, you can import plugins directly from their specific paths instead of /plugins like import jwt plugin from /plugins/jwt instead.
  • Most of the size is cause we have everything in one package. We could split plugins, clients, and other components into separate packages to make it leaner. But, the convenience of having everything in a single package better-auth feels like a bigger win in many ways.
<!-- gh-comment-id:2558225899 --> @Bekacru commented on GitHub (Dec 21, 2024): Could you try adding this to your next config for your use case ```ts experimental: { optimizePackageImports: ["better-auth"] } ``` Regarding the bundle size: - First, this is server-side, so it shouldn't be a major concern. The client bundle should remain very small. - We ship Kysely with Better Auth, which accounts for at least a quarter of the bundle size. - To enable better tree-shaking, you can import plugins directly from their specific paths instead of `/plugins` like import jwt plugin from `/plugins/jwt` instead. - Most of the size is cause we have everything in one package. We could split plugins, clients, and other components into separate packages to make it leaner. But, the convenience of having everything in a single package `better-auth` feels like a bigger win in many ways.
Author
Owner

@daveycodez commented on GitHub (Dec 21, 2024):

I tried both and I'm still seeing the warnings, I'll have to setup a barebones project to see if this occurs or maybe even it's shadcn or something else causing it. I'm mainly just trying to suppress the warnings for a cleaner dev console but can't seem to find a good method, Webpack config isn't working.

<!-- gh-comment-id:2558234002 --> @daveycodez commented on GitHub (Dec 21, 2024): I tried both and I'm still seeing the warnings, I'll have to setup a barebones project to see if this occurs or maybe even it's shadcn or something else causing it. I'm mainly just trying to suppress the warnings for a cleaner dev console but can't seem to find a good method, Webpack config isn't working.
Author
Owner

@daveycodez commented on GitHub (Dec 21, 2024):

Adding this to next.config.json is suppressing it correctly. All the other warningsFilter options etc weren't working but I discovered this. I'm cool with them just being suppressed tbh, if anyone stumbles here from Google:

Suppress [webpack.cache.PackFileCacheStrategy] Serializing big strings warnings in Next.js console

webpack: (config) => {
    config.infrastructureLogging = { level: "error" }
    return config
  },
<!-- gh-comment-id:2558236107 --> @daveycodez commented on GitHub (Dec 21, 2024): Adding this to next.config.json is suppressing it correctly. All the other warningsFilter options etc weren't working but I discovered this. I'm cool with them just being suppressed tbh, if anyone stumbles here from Google: ### Suppress [webpack.cache.PackFileCacheStrategy] Serializing big strings warnings in Next.js console ```ts webpack: (config) => { config.infrastructureLogging = { level: "error" } return config }, ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17163