Skip to content

fix(cli): import defineNitroPlugin in evlog Nitro plugins - #1292

Merged
AmanVarshney01 merged 6 commits into
mainfrom
fix/evlog-nitro-plugin-imports
Oct 22, 2026
Merged

AmanVarshney01 merged 6 commits into
mainfrom
fix/evlog-nitro-plugin-imports

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

TanStack Start with backend: self and the evlog addon crashed with ReferenceError: defineNitroPlugin is not defined whenever Nitro was on (webDeploy docker/vercel/prisma, or the axiom addon). This imports the Nitro v3 plugin helper in every Nitro plugin evlog generates for TanStack Start, and fixes the auth plugin so it typechecks and identifies users on Nitro v3.

Root cause

apps/cli/src/helpers/addons/evlog-setup.ts only added import { definePlugin as defineNitroPlugin } from "nitro" to the Axiom drain plugin. The FS drain plugin (server/plugins/evlog-drain.ts) and the auth plugin (server/plugins/evlog-auth.ts) relied on the defineNitroPlugin global, which Nuxt auto-imports but Nitro v3 does not (current docs: import { definePlugin } from "nitro").

With the import added, the auth plugin also failed to typecheck: createAuthIdentifier expects a Nitro v2 event, and in a Nitro v3 request hook the evlog logger is not set yet (module plugins register after server/plugins), so it never identified anyone. TanStack Start now follows evlog's documented pattern, which the Nuxt template already uses: createAuthMiddleware runs from server/middleware/evlog-auth.ts (Nitro v3 defineHandler, with useLogger(event) from evlog/nitro/v3). Middleware runs before the route handler, so requests that throw are tagged with the user too. Nuxt output is unchanged.

Added a tanstack-start-self-auth-evlog generated-build sample (sqlite, drizzle, oRPC, Better Auth, evlog, webDeploy docker). Its check-types covers server/plugins, so it fails with TS2304 on main.

Fixes #1251

Verification

  • Reproduced on main: generated stack gave a 500 with ReferenceError: defineNitroPlugin is not defined in bun run dev, and tsc reported TS2304 for both plugins.
  • With the fix: bun run dev gives 200 on /. check-types is clean. bun run build and node .output/server/index.mjs give 200. After sign-up, signed-in /dashboard and /api/rpc/privateData wide events carry userId (built server and dev FS drain).
  • BTS_BUILD_SAMPLES=1 BTS_BUILD_SAMPLE_FILTER=tanstack-start-self-auth-evlog bun test test/generated-builds.test.ts: 1 pass.
  • bun run check: clean.
  • bun run test:ci: 112 pass, 0 fail.

Summary by CodeRabbit

  • Improvements
    • Generated Nitro v3 setups now support the evlog plugin with both Axiom and filesystem drains.
    • TanStack Start and Nuxt setup now generate authentication middleware for Evlog, replacing the previous TanStack Start auth plugin file and preserving existing Evlog auth plugins in Nuxt.
  • New Features
    • Added a generated-build sample for TanStack Start with a self-hosted backend and Docker web deployment.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
create-better-t-stack-web Ready Ready Preview Oct 22, 2026 6:23pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T08:04:49.153436Z ed8cb2c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Generated TanStack Start evlog setup imports the Nitro v3 plugin API for both drain types. It generates Better Auth middleware and adds a self-hosted TanStack Start build sample.

Changes

TanStack Start evlog

Layer / File(s) Summary
Generated Nitro drain behavior
apps/cli/src/helpers/addons/evlog-setup.ts
The drain generator adds the Nitro v3 import for Axiom and filesystem drains.
Better Auth middleware generation
apps/cli/src/helpers/addons/evlog-setup.ts, apps/cli/test/generated-builds/samples.ts
TanStack Start setup generates auth middleware using createAuthMiddleware and useLogger(event). Nuxt setup no longer checks for or removes an existing Evlog auth plugin. The self-hosted sample configures Better Auth, oRPC, SQLite/Drizzle, evlog, the todo example, and Docker web deployment.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to d8b59

Add the generated-build checks before merging so regressions in the generated auth and evlog runtime path are detected.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning The change removes Nuxt cleanup that deleted an existing server/plugins/evlog-auth.ts file. Issue #1251 targets TanStack Start, and the PR description states that Nuxt output is unchanged. This Nuxt… Restore the existing Nuxt cleanup behavior, or provide a linked coding requirement and regression coverage that justifies retaining obsolete Nuxt auth plugins.
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: adding the missing defineNitroPlugin import to generated Evlog Nitro plugins.
Linked Issues check Passed Issue #1251 requires Nitro v3 support for generated TanStack Start evlog code. The generator now adds import { definePlugin as defineNitroPlugin } from "nitro" to both filesystem and Axiom drain plu…
Full details: Linked Issues check

Explanation

Issue #1251 requires Nitro v3 support for generated TanStack Start evlog code. The generator now adds import { definePlugin as defineNitroPlugin } from "nitro" to both filesystem and Axiom drain plugins. It now generates TanStack Start auth middleware with defineHandler, useLogger, and createAuthMiddleware, so it no longer emits the affected Nitro v2 auth plugin. The new tanstack-start-self-auth-evlog generated-build sample provides regression coverage. The reported typecheck, build, runtime, and test results support compliance.

Full details: Out of Scope Changes check

Explanation

The change removes Nuxt cleanup that deleted an existing server/plugins/evlog-auth.ts file. Issue #1251 targets TanStack Start, and the PR description states that Nuxt output is unchanged. This Nuxt behavior change is not required by the linked issue and can leave an obsolete auth plugin in generated projects.

Resolution

Restore the existing Nuxt cleanup behavior, or provide a linked coding requirement and regression coverage that justifies retaining obsolete Nuxt auth plugins.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 10ed94a7-99c3-4c88-8afb-f970b25f5787
📥 Commits

Reviewing files that changed from the base of the PR and between 09edd06 and ed8cb2c.

📒 Files selected for processing: 2
  • apps/cli/src/helpers/addons/evlog-setup.ts
  • apps/cli/test/generated-builds/samples.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

…tart

evlog documents createAuthMiddleware in a server middleware, which the
Nuxt template already uses. TanStack Start now does the same: a
server/middleware/evlog-auth.ts handler with Nitro v3's defineHandler,
created once at startup, replacing the response-hook plugin. Middleware
runs before the route handler, so requests that throw are now tagged
with the user too. An existing evlog auth plugin is removed when the
addon is set up again.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d6a3abb2-72f0-47c1-8f46-81081754117a
📥 Commits

Reviewing files that changed from the base of the PR and between ed8cb2c and 67dd90b.

📒 Files selected for processing: 1
  • apps/cli/src/helpers/addons/evlog-setup.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

The CLI only targets the latest scaffold, so the addon no longer looks
for and deletes the previous server/plugins/evlog-auth.ts in Nuxt or
TanStack Start projects.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments: 1
apps/cli/test/generated-builds/samples.ts: 1

287-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add runtime checks to the evlog sample.

The sample skips auth:generate and the TanStack Start runtime probe. Add both checks. auth-generate preserves the generated Better Auth schema, and start-auth-runtime boots the built server and exercises requests through the generated middleware and Nitro plugin.

Suggested fix
   {
     name: "tanstack-start-self-auth-evlog",
+    checks: ["auth-generate", "start-auth-runtime"],
     config: {

ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee320bd9-64b3-4428-a8bb-b5ac71b7322d
📥 Commits

Reviewing files that changed from the base of the PR and between 67dd90b and d8b592a.

📒 Files selected for processing: 2
  • apps/cli/src/helpers/addons/evlog-setup.ts
  • apps/cli/test/generated-builds/samples.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@AmanVarshney01
AmanVarshney01 merged commit f463ec6 into main Oct 22, 2026
11 checks passed
@AmanVarshney01
AmanVarshney01 deleted the fix/evlog-nitro-plugin-imports branch October 22, 2026 18:29

This branch was successfully deployed

1 active deployment
Preview — d8b592aa Deployed Oct 22, 2026 by vercel[bot]
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.

TanStack Start + evlog: web app crashes with defineNitroPlugin is not defined

1 participant