get-convex / get-convex/better-auth

@convex-dev/better-auth` fails with "boolean(...).meta is not a function" on Convex 1.28.0

Open
#145 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
764
Forks
126
PR merge metrics
No merged PRs in 30d

Description

# @convex-dev/better-auth` fails with "boolean(...).meta is not a function" on Convex

## Environment

- **Package**: `@convex-dev/better-auth` version `^0.9.6`
- **Convex**: `^1.28.0`
- **better-auth**: `1.3.27`
- **@better-auth/expo**: `1.3.27`
- **OS**: Windows 10

## Error Message

```
✖ Error: Unable to start push to https://adjoining-emu-712.convex.cloud
✖ Error fetching POST https://adjoining-emu-712.convex.cloud/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following error:
Failed to analyze auth.js: Uncaught TypeError: xt.boolean(...).meta is not a function
```

## Steps to Reproduce

1. Install dependencies:
```json
{
"@convex-dev/better-auth": "^0.9.6",
"convex": "^1.28.0",
"better-auth": "1.3.27"
}
```

2. Configure Better Auth in `convex/convex.config.ts`:
```typescript
import betterAuth from "@convex-dev/better-auth/convex.config";
const app = defineApp();
app.use(betterAuth);
```

3. Create `convex/auth.ts`:
```typescript
import { createClient } from "@convex-dev/better-auth";
import { components } from "./_generated/api";
import { DataModel } from "./_generated/dataModel";

export const authComponent = createClient(components.betterAuth);
```

4. Run `npx convex dev` or push to Convex
5. Error occurs during module analysis

## Expected Behavior

Convex should successfully analyze the Better Auth component without errors, allowing the auth component to initialize properly.

## Actual Behavior

Convex fails to analyze the module with the error `boolean(...).meta is not a function`, indicating that the Better Auth package is using a deprecated or removed Convex validator API.

## Code Context

**convex/convex.config.ts:**
```typescript
import { defineApp } from "convex/server";
import workpool from "@convex-dev/workpool/convex.config";
import betterAuth from "@convex-dev/better-auth/convex.config";

const app = defineApp();
app.use(workpool, { name: "applicationWorkpool" });
app.use(betterAuth);

export default app;
```

**convex/auth.ts:**
```typescript
import { createClient, type GenericCtx } from "@convex-dev/better-auth";
import { convex } from "@convex-dev/better-auth/plugins";
import { betterAuth } from "better-auth";
import { expo } from "@better-auth/expo";
import { components } from "./_generated/api";
import { DataModel } from "./_generated/dataModel";
import { query } from "./_generated/server";

export const authComponent = createClient(components.betterAuth);

export const createAuth = (
ctx: GenericCtx,
{ optionsOnly } = { optionsOnly: false }
) => {
return betterAuth({
logger: {
disabled: optionsOnly,
},
trustedOrigins: ["job://", "exp://"],
database: authComponent.adapter(ctx),
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
socialProviders: {
google: {
prompt: "select_account",
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
github: {
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
prompt: "select_account",
},
},
plugins: [expo(), convex()],
});
};

export const getCurrentUser = query({
args: {},
handler: async (ctx) => {
return authComponent.getAuthUser(ctx);
},
});
```

## Attempted Workarounds

1. ✅ Upgraded `@convex-dev/better-auth` to `^0.10.0` - Same error
2. ✅ Downgraded Convex to `^1.25.4` - Same error
3. ✅ Used type assertion: `components.betterAuth as any` - TypeScript error resolved but runtime error persists
4. ✅ Aligned Convex versions across all packages - No change

## Investigation

The error suggests that:
- The `.meta()` method doesn't exist on boolean validators in Convex 1.28.0 (and possibly 1.25.4+)
- `@convex-dev/better-auth` 0.9.6 is likely using an older Convex validator API
- Convex may have removed or changed the `.meta()` API in recent versions

## Questions

1. Is `@convex-dev/better-auth` 0.9.6 compatible with Convex 1.28.0?
2. What is the minimum/maximum Convex version supported by this package?
3. Is there a newer version that supports Convex 1.28.0?
4. What changed in Convex validator API that removed `.meta()`?
5. What is the recommended workaround or migration path?

## Additional Notes

Also experiencing TypeScript errors about component reference type mismatches, but the runtime error is the blocking issue.

I can provide a minimal reproduction repository if needed.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the listed package versions using `npx convex dev`, starting from `convex/convex.config.ts` and `convex/auth.ts`. Trace the `@convex-dev/better-auth` component loading path and its validator API usage; done means the modules analyze successfully without the `boolean(...).meta is not a function` error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.