Skip to content

test: fix flaky tests - #24

Merged
Brooooooklyn merged 5 commits into
mainfrom
fix/auth-integration-issues
Mar 20, 2026
Merged

Brooooooklyn merged 5 commits into
mainfrom
fix/auth-integration-issues

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Mar 19, 2026 •

Copy link
Copy Markdown
Member

Note

Medium Risk
Changes Better Auth option resolution to merge user-provided object configs with defaults and adjusts Vite dev SSR resolution via new better-auth/* aliases, which could subtly affect auth/runtime behavior in dev and production. Test changes are low risk but these runtime/config changes warrant verification across different auth configurations and package managers (e.g., pnpm strict mode).

Overview
Improves Better Auth configuration handling by merging default options with object-style user configs (in both schema generation and runtime), instead of replacing defaults entirely.

Reduces auth-related dev-server reloads by adding a Vite serve-only alias setup for better-auth client subpaths so SSR can resolve them without relying on hoisted dependencies.

Stabilizes integration tests by warming up the Vite dev server before running Playwright flows and updates the project list CLI test expectations to use *.staging.void.app URLs.

Written by Cursor Bugbot for commit e7833c6. This will update automatically on new commits. Configure here.

- Use IF NOT EXISTS for SQLite ADD COLUMN in auth migrations (D1
  supports it since SQLite 3.35+), matching PostgreSQL behavior
- Pre-resolve better-auth client subpaths in Vite SSR dep optimizer
  via resolve.alias to prevent lazy discovery causing disruptive
  program reloads on first auth page load with cold cache
- Update projects-command test to expect staging.void.app URLs after
  default auth env was switched to staging in f2a8d68

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment thread packages/void/src/plugin-routing.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c57dc9b104

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/void/src/runtime/auth-migrations.ts Outdated
Comment thread packages/void/src/plugin-routing.ts Outdated
Brooooooklyn and others added 2 commits March 19, 2026 16:51
The first request to a cold Vite dev server triggers SSR dependency
optimization (drizzle-orm, vue, hono, etc.), causing multiple program
reloads that exceed the 10s Playwright timeout. Add a warmup fetch in
beforeAll to let the reloads settle before tests run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The include list caused Vite to attempt pre-bundling the aliased
better-auth modules, which involves reading package.json. Since the
aliases point to raw .mjs files, Vite tried to JSON-parse JavaScript
source, crashing the dev server on CI. The resolve.alias alone is
sufficient — it resolves bare specifiers to absolute file paths,
preventing lazy SSR dep discovery without needing pre-bundling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d02b80467

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/void/test/integration/kitchen-sink.test.ts
SQLite does not support IF NOT EXISTS on ALTER TABLE ADD COLUMN —
only PostgreSQL does. The SQLite path correctly relies on the
check-then-act pattern (PRAGMA table_info → skip existing columns)
in applySqliteAuthMigrations(). Revert to the original behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn changed the title fix: auth integration hardening and test fixes test: fix flaky tests Mar 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread packages/void/src/runtime/better-auth-shared.ts
When defineAuth() received a plain object (not a function),
resolveUserConfig returned the user config directly, silently
discarding all security defaults — secret, baseURL, basePath,
database, and trustedOrigins. The object form now shallow-merges
user overrides on top of defaults, matching the safe behavior of
the no-config path while preserving the function form's full
control.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Brooooooklyn
Brooooooklyn force-pushed the fix/auth-integration-issues branch from ee1bfd0 to e7833c6 Compare March 20, 2026 10:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7833c615c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/void/src/runtime/better-auth-shared.ts
@Brooooooklyn
Brooooooklyn merged commit ed45a8a into main Mar 20, 2026
13 of 14 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/auth-integration-issues branch March 20, 2026 10:56
Brooooooklyn added a commit that referenced this pull request Apr 17, 2026
Even after #24 the CI is still flaky for some cases. I've bumped the
timeouts.

Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Co-authored-by: Brooooooklyn <3468483+Brooooooklyn@users.noreply.github.com>
cpojer pushed a commit that referenced this pull request Sep 11, 2026
The dashboard will be rewritten — skip deploying it in both staging
and production pipelines. Also reverts the esmExternalRequirePlugin
workaround from #23 since it's no longer needed.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Brooooooklyn added a commit that referenced this pull request Oct 26, 2026
Fixes #565

## Problem

With auth on, `vp dev` aliases five better-auth subpaths to files in
Void's own copy of better-auth. Each alias used a **string** `find`, and
in Vite a string `find` also matches every deeper path:

```
alias find 'better-auth/client'  →  …/better-auth/dist/client/index.mjs

import 'better-auth/client'          →  …/dist/client/index.mjs          ✓
import 'better-auth/client/plugins'  →  …/dist/client/index.mjs/plugins  ✗ (no such file)
```

So any app that passes a Better Auth client plugin (`adminClient()`,
`organizationClient()`, …) to `createAuthClient` broke in dev:

- the client failed with `Failed to resolve import
"better-auth/client/plugins"`;
- SSR returned 500 (`No such module …`).

`vp build` adds no alias, so it was fine.

## Fix

Each `find` is now an anchored RegExp, `^better-auth/<sub>$`. Vite's
alias API has only two kinds of `find`: a string, which also matches
deeper paths, or a RegExp. So a RegExp is the only way to get an exact
match. The repo already does the same (`{ find: /^void$/ }` in
`cli/wrapper.ts`).

```
                                 before (string)        after (exact)
better-auth/client               Void's copy ✓          Void's copy ✓   (unchanged)
better-auth/react|vue|svelte|solid  Void's copy ✓       Void's copy ✓   (unchanged)
better-auth/client/plugins       broken path ✗          normal resolution ✓
```

The five exact ids get the same replacement in every Vite step that
reads `resolve.alias`:

- the alias plugin;
- `vite:pre-alias`;
- SSR externalization;
- the dependency optimizer.

So the cold-cache reload protection from #24 (the reason the aliases
exist) is kept.

## Checks

- **New test** in `plugin-routing.test.ts`. It starts a real Vite dev
server with auth on and resolves:
- `better-auth/client` and `/react` from an app file, which has no
better-auth of its own. They resolve only through the aliases, to Void's
copy.
- `better-auth/client/plugins` from inside the package. It resolves to
`dist/client/plugins/index.mjs`.
- **Mutation check:** the test fails with the old string `find` and with
no aliases at all.
- **Scratch app from the issue:** a React pages app, auth on,
`adminClient()` from `better-auth/client/plugins`, cold cache, `vp dev`.

  ```
                   before                     after
SSR GET / 500 No such module 200, authClient.admin.listUsers is a
function
  client module    500 Failed to resolve      200
  ```

- `void` typecheck, lint and fmt pass. Affected tests (`vp run test`,
508 files) pass.

## Not changed here

- **`client/plugins` is not pinned to Void's copy.** The issue mentions
this as optional. Without it, the user's own better-auth provides
`client/plugins`, as in `vp build`, and Vite discovers it like any other
dependency. That costs one optimizer reload on the first cold-cache page
that imports it. Pinning would point the import at Void's better-auth
version instead of the one the app installed. That's a product decision,
so I left it out.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants