nextauthjs/next-auth · warning

adapter_typeorm_updating_entities

adapter_typeorm_updating_entities

Error message

[next-auth][warn][adapter_typeorm_updating_entities]
https://authjs.dev/reference/warnings#adapter_typeorm_updating_entities

What it means

The TypeORM adapter can auto-sync schema changes to your database via dataSource.synchronize(). Because this mutates your database schema automatically (risky in production), the adapter warns loudly when it is about to run synchronize because `synchronize` was not explicitly set to false. It is a warning, not a failure — schema sync still happens.

Source

Thrown at packages/adapter-typeorm/src/utils.ts:104

  }

  return false
}

export async function updateConnectionEntities(
  dataSource: DataSource,
  entities: any[]
) {
  if (!entitiesChanged(dataSource.entityMetadatas, entities)) return

  // @ts-expect-error
  dataSource.entityMetadatas = entities

  // @ts-expect-error
  await dataSource.buildMetadatas()

  if (dataSource.options.synchronize !== false) {
    console.warn(
      "[next-auth][warn][adapter_typeorm_updating_entities]",
      "\nhttps://authjs.dev/reference/warnings#adapter_typeorm_updating_entities"
    )
    await dataSource.synchronize()
  }
}

View on GitHub (pinned to a1a16a5a77)

Solutions

  1. Set `synchronize: false` in the TypeORM DataSource options and manage schema with migrations
  2. Use `migrationsRun: true` with generated migration files instead of automatic synchronize
  3. Keep synchronize enabled only in development and acknowledge/silence the warning there

Example fix

// before
export const adapter = TypeORMAdapter(connectionString)
// after
export const adapter = TypeORMAdapter({
  type: "postgres",
  url: process.env.DATABASE_URL,
  synchronize: false,
  migrationsRun: true,
  entities: [...models]
})
Defensive patterns

Strategy: validation

Validate before calling

if (dataSource.options.synchronize !== false) {
  console.warn("TypeORM adapter will auto-sync your schema; set synchronize: false for production")
}

Type guard

function isSchemaSafe(opts: { synchronize?: boolean }): boolean {
  return opts.synchronize === false
}

Prevention

When it happens

Trigger: Instantiating the TypeORM adapter without `synchronize: false` in the DataSource options; getManager/updateConnectionEntities then builds entity metadata and runs dataSource.synchronize(), emitting this warning first.

Common situations: Bootstrapping a NextAuth app in development where the adapter creates/alters tables automatically; deploying to production with default options and discovering unintended schema migrations; upgrading TypeORM and entities so metadata rebuild triggers sync.

Related errors


AI-assisted analysis of nextauthjs/next-auth@a1a16a5a77 (2026-08-28). Data as JSON: /api/errors/78e783155016c551. Report an issue: GitHub.