Skip to content

OverwriteModelError when using experimental-build-mode compile #8533

@mattbolt

Description

@mattbolt

Link to reproduction

No response

Environment Info

Payload: 3.0.0-beta.110
Node: 18.20.4
Next.js: 15.0.0-canary.104

Describe the Bug

When visiting the root url before visiting the /admin url and the database is empty, you get the following error:

⨯ OverwriteModelError: Cannot overwrite _pages_versions model once compiled.
    at Mongoose.model (/Users/***MASKED***/node_modules/mongoose/lib/index.js:587:13)
    at /Users/***MASKED***/.next/server/chunks/8914.js:90:18405
    at Array.forEach (<anonymous>)
    at Object.tK [as init] (/Users/***MASKED***/.next/server/chunks/8914.js:90:18042)
    at eD.init (/Users/***MASKED***/.next/server/chunks/8914.js:95:14493)
    at async eF (/Users/***MASKED***/.next/server/chunks/8914.js:95:16814) {
  digest: '2684875208'
}

Reproduction Steps

Build the app using output: "standalone", in next.config.js ... and compile using next build --experimental-build-mode compile.

If you subsequently visit the admin page after hitting the home page, you still get the error. However if you restart the server, the database gets initialised properly and you are asked to create the first user.

Also noting that if you call next-build --experimental-build-mode generate after the compile command and before visiting the root url, you do not get the above error.

Adapters and Plugins

formBuilderPlugin, nestedDocsPlugin, redirectsPlugin, s3Storage, seoPlugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions