Skip to content

Load logging in init templates#727

Merged
dahlia merged 4 commits intofedify-dev:2.0-maintenancefrom
dahlia:bugfix/nitro-next-logging
Apr 26, 2026
Merged

Load logging in init templates#727
dahlia merged 4 commits intofedify-dev:2.0-maintenancefrom
dahlia:bugfix/nitro-next-logging

Conversation

@dahlia
Copy link
Copy Markdown
Member

@dahlia dahlia commented Apr 25, 2026

Summary

Fixes #725.

The Nitro and Next.js fedify init templates already generated LogTape configuration files, but those files were not imported by the generated server entrypoints. As a result, Fedify logs used the default LogTape state instead of the scaffolded configuration.

This PR adds packages/init/src/templates/nitro/server/plugins/logging.ts.tpl, which imports server/logging.ts through Nitro’s server plugin startup path.

This PR also adds packages/init/src/templates/next/instrumentation.ts.tpl, which imports logging.ts from Next.js' register() hook when NEXT_RUNTIME is nodejs.

Astro and SolidStart are intentionally left out here because they were introduced after the 2.0.x line. This keeps the fix suitable for the 2.0 maintenance branch; the 2.1.x branch can carry the same fix forward and handle those integrations separately.

Tests

  • deno task check in packages/init
  • pnpm --filter @fedify/init test
  • deno check packages/init/src/webframeworks.test.ts
  • deno run -A packages/init/src/test/execute.ts init /tmp/fedify-init-725-nitro -w nitro -p npm -k in-memory -m in-process --dry-run
  • deno run -A packages/init/src/test/execute.ts init /tmp/fedify-init-725-next -w next -p npm -k in-memory -m in-process --dry-run

Add startup wiring for generated Nitro and Next.js applications so their
LogTape configuration modules are actually loaded before Fedify handles
requests.  Nitro projects now get a server plugin, while Next.js projects
get an instrumentation register hook scoped to the Node.js runtime.

Add regression coverage for both framework initializers and document the
fix in the changelog.

Fixes fedify-dev#725

Assisted-by: Codex:gpt-5.5
@dahlia dahlia requested a review from Copilot April 25, 2026 13:58
@dahlia dahlia self-assigned this Apr 25, 2026
@dahlia dahlia added component/cli CLI tools related integration/next Next.js integration (@fedify/next) labels Apr 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bbbb8eb4-951a-4422-bf2c-c40b95e3c3b1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@issues-auto-labeler issues-auto-labeler Bot added breaking change Requires backward-incompatible change component/build Build system and packaging labels Apr 25, 2026
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 25, 2026

@codex review

@dahlia dahlia removed breaking change Requires backward-incompatible change component/build Build system and packaging labels Apr 25, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ 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".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes @fedify/init scaffolding for Nitro and Next.js so the generated logging.ts configuration is actually loaded during server startup, ensuring Fedify uses the intended LogTape configuration (per #725).

Changes:

  • Nitro: add a server plugin that imports the generated server/logging.ts at startup.
  • Next.js: add an instrumentation.ts register() hook that loads logging.ts in the Node.js runtime.
  • Add tests asserting the generated templates include the expected wiring, and document the fix in the changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/init/src/webframeworks.ts Wires new Nitro plugin + Next instrumentation into generated file sets.
packages/init/src/webframeworks.test.ts Adds template-level tests to assert logging wiring exists.
packages/init/src/templates/nitro/server/plugins/logging.ts.tpl New Nitro plugin template that imports server/logging.ts.
packages/init/src/templates/next/instrumentation.ts.tpl New Next.js instrumentation hook to import logging.ts in Node runtime.
CHANGES.md Documents the init template fix for 2.0.15 and links #725.

Comment thread packages/init/src/templates/next/instrumentation.ts.tpl
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the @fedify/init package to ensure that generated logging.ts files are correctly loaded during server startup for Nitro and Next.js templates. For Nitro, a new server plugin is introduced, while for Next.js, an instrumentation.ts file with a register() hook is added. The PR also includes corresponding updates to the framework configuration and new regression tests to verify the presence and content of these files. I have no feedback to provide.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
packages/init/src/webframeworks.ts 27.01% <100.00%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Avoid reading process.env directly in the generated Next.js
instrumentation hook.  Using globalThis.process?.env keeps the hook safe
when instrumentation is evaluated outside the Node.js runtime, while still
loading the LogTape setup for Node.js requests.

Updates the initializer regression test to assert the guarded runtime check.

Review comment: fedify-dev#727 (comment)

Assisted-by: Codex:gpt-5.5
@dahlia dahlia requested a review from Copilot April 25, 2026 14:53
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 25, 2026

@codex review

@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 25, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes the Nitro and Next.js project templates to ensure their generated logging.ts files are loaded during server startup. Nitro projects now include a server plugin that imports the LogTape configuration, and Next.js projects include an instrumentation.ts file with a register() hook for the same purpose. The PR also adds regression tests and updates the changelog. I have no feedback to provide.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes fedify init scaffolding for Nitro and Next.js by ensuring the generated logging.ts (LogTape configuration) is actually loaded during server startup, matching user expectations and resolving #725.

Changes:

  • Nitro: add a Nitro server plugin that imports server/logging.ts at startup.
  • Next.js: add instrumentation.ts that imports ./logging from register() when running in the Node.js runtime.
  • Add unit tests to assert the generated templates include the new startup wiring, and document the fix in the changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/init/src/webframeworks.ts Wires new Nitro plugin and Next.js instrumentation template into generated file sets.
packages/init/src/webframeworks.test.ts Adds tests asserting Nitro/Next templates load logging at startup.
packages/init/src/templates/nitro/server/plugins/logging.ts.tpl New Nitro plugin that imports server/logging.ts via Nitro’s plugin startup path.
packages/init/src/templates/next/instrumentation.ts.tpl New Next.js register() hook that conditionally imports logging in Node.js runtime.
CHANGES.md Adds changelog entry describing the @fedify/init template fix and links #725.

Copy link
Copy Markdown

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

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: 79443df343

ℹ️ 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/init/src/templates/next/instrumentation.ts.tpl Outdated
Use the documented process.env.NEXT_RUNTIME guard in the generated Next.js
instrumentation hook.  Next.js relies on this pattern for runtime-specific
imports, so the Node-only logging module is not pulled into Edge bundles.

Updates the initializer regression test to assert the documented runtime
check.

Review comment: fedify-dev#727 (comment)

Assisted-by: Codex:gpt-5.5
@dahlia dahlia requested a review from Copilot April 25, 2026 15:07
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 25, 2026

@codex review

@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 25, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the @fedify/init package to ensure that the generated logging.ts files are automatically loaded during server startup for Nitro and Next.js templates. Nitro projects now include a server plugin for LogTape configuration, while Next.js projects utilize an instrumentation.ts file with a register() hook. The changes include new template files, updates to the framework configurations, and regression tests. I have no feedback to provide.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes @fedify/init scaffolding so framework templates that generate a logging.ts configuration also ensure it is executed during server startup, restoring expected LogTape/Fedify logging behavior in generated apps.

Changes:

  • Nitro: adds a server/plugins/logging.ts plugin to import server/logging.ts during Nitro startup.
  • Next.js: adds instrumentation.ts to import ./logging via Next’s register() hook when running in the Node.js runtime.
  • Adds tests to assert the generated templates include the expected wiring, and documents the fix in CHANGES.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/init/src/webframeworks.ts Wires new Nitro plugin and Next.js instrumentation file into generated template outputs.
packages/init/src/webframeworks.test.ts Adds regression tests asserting the new logging-wiring files are generated and contain expected imports.
packages/init/src/templates/nitro/server/plugins/logging.ts.tpl New Nitro server plugin template that imports the generated logging configuration.
packages/init/src/templates/next/instrumentation.ts.tpl New Next.js instrumentation template intended to import logging config during Node runtime startup.
CHANGES.md Changelog entry documenting the Nitro/Next template fix for issue #725.

Comment thread packages/init/src/templates/next/instrumentation.ts.tpl
Comment thread packages/init/src/webframeworks.test.ts
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

@dahlia dahlia requested review from 2chanhaeng and sij411 April 25, 2026 15:28
@dahlia dahlia merged commit 1cb9a6b into fedify-dev:2.0-maintenance Apr 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli CLI tools related integration/next Next.js integration (@fedify/next)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants