Skip to content

fix(bundler): start manifest app in metadataOnly mode#5910

Merged
killagu merged 1 commit intonextfrom
agent/egg-dev/84a193fb
May 2, 2026
Merged

fix(bundler): start manifest app in metadataOnly mode#5910
killagu merged 1 commit intonextfrom
agent/egg-dev/84a193fb

Conversation

@killagu
Copy link
Copy Markdown
Contributor

@killagu killagu commented May 2, 2026

Summary

  • pass metadataOnly: true when generate-manifest starts the app
  • add a minimal generate-manifest repro that mimics the cnpmcore beforeClose failure when metadataOnly is missing
  • verify the generated manifest is written and the synthetic beforeClose path is not triggered

Tests

  • pnpm --filter @eggjs/egg-bundler exec vitest run test/generate-manifest.test.ts --reporter verbose
  • pnpm --filter @eggjs/egg-bundler test
  • pnpm --filter @eggjs/egg-bundler typecheck
  • pnpm --filter @eggjs/egg-bundler lint
  • pnpm exec oxfmt --check tools/egg-bundler/src/scripts/generate-manifest.mjs tools/egg-bundler/test/generate-manifest.test.ts

Refs: EGG-18

Summary by CodeRabbit

  • Improvements
    • Manifest generation now runs in metadata-only mode and exits immediately after producing the manifest, skipping full lifecycle shutdown steps.
  • Tests
    • Added and updated tests to verify metadata-only startup, confirm manifest creation, and assert that shutdown/close side-effects are skipped in this mode.

Copilot AI review requested due to automatic review settings May 2, 2026 03:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6f44481-9a31-4dc0-bd90-46dc14204897

📥 Commits

Reviewing files that changed from the base of the PR and between 43f924d and 65e7513.

📒 Files selected for processing (3)
  • tools/egg-bundler/src/scripts/generate-manifest.mjs
  • tools/egg-bundler/test/ManifestLoader.test.ts
  • tools/egg-bundler/test/generate-manifest.test.ts
✅ Files skipped from review due to trivial changes (1)
  • tools/egg-bundler/src/scripts/generate-manifest.mjs
🚧 Files skipped from review as they are similar to previous changes (2)
  • tools/egg-bundler/test/generate-manifest.test.ts
  • tools/egg-bundler/test/ManifestLoader.test.ts

📝 Walkthrough

Walkthrough

The manifest generator starts the framework with metadataOnly: true, writes the manifest, flushes stdio, and calls process.exit(0) instead of awaiting app.close(). Tests added/updated verify metadataOnly is passed and that close-related side effects are not executed.

Changes

Metadata-Only Manifest Generation

Layer / File(s) Summary
Data / Callsite
tools/egg-bundler/src/scripts/generate-manifest.mjs
framework.start(...) now receives metadataOnly: true in the start options.
Core Behavior
tools/egg-bundler/src/scripts/generate-manifest.mjs
Replaces await app.close() with a new flushWritable(stream) helper that flushes process.stdout/process.stderr and then calls process.exit(0).
Test Harness
tools/egg-bundler/test/generate-manifest.test.ts
New Vitest writes a temporary framework.mjs that persists the start(options) payload and exposes a stubbed loader.generateManifest() result.
Integration Verification
tools/egg-bundler/test/generate-manifest.test.ts
Subprocess run asserts start-options.json includes metadataOnly: true, verifies .egg/manifest.json exists, and asserts close-related markers (app-close-called, before-close-called) are absent.
Related Test Update
tools/egg-bundler/test/ManifestLoader.test.ts
Adjusts a test expectation to assert the framework fixture’s close() side-effect file is absent (read fails with ENOENT).

Sequence Diagram

sequenceDiagram
    participant Script as GenerateManifest.mjs
    participant Framework as framework.mjs
    participant Loader as loader.generateManifest
    participant FS as Filesystem
    participant Proc as Process

    Script->>Framework: start({ ..., metadataOnly: true })
    Framework->>Loader: generateManifest()
    Loader-->>Framework: manifest JSON
    Framework-->>Script: manifest result
    Script->>FS: write .egg/manifest.json
    Script->>Proc: flush stdout/stderr
    Script->>Proc: process.exit(0)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • jerryliang64
  • fengmk2

Poem

🐰 I nudged a flag, made startup light and free,

metadata whispers, "Just look, don't cling to me."
No close to linger, no hooks left to call,
The manifest sleeps in .egg — tidy, small.
Hooray for short runs! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: starting the manifest app in metadataOnly mode, which is the core fix implemented across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/egg-dev/84a193fb

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 2, 2026

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65e7513
Status: ✅  Deploy successful!
Preview URL: https://fc044c91.egg-cci.pages.dev
Branch Preview URL: https://agent-egg-dev-84a193fb.egg-cci.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.03%. Comparing base (d73b90c) to head (65e7513).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5910      +/-   ##
==========================================
- Coverage   85.03%   85.03%   -0.01%     
==========================================
  Files         665      665              
  Lines       19108    19108              
  Branches     3719     3719              
==========================================
- Hits        16249    16248       -1     
- Misses       2466     2467       +1     
  Partials      393      393              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 generate-manifest script to enable metadataOnly mode when starting the application. This change ensures that lifecycle hooks, such as beforeClose, are skipped during the manifest generation process. Additionally, a new test file generate-manifest.test.ts has been introduced to validate that the metadataOnly flag is correctly applied and that the expected files are generated or skipped. I have no feedback to provide.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 2, 2026

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65e7513
Status: ✅  Deploy successful!
Preview URL: https://99b4d7fd.egg-v3.pages.dev
Branch Preview URL: https://agent-egg-dev-84a193fb.egg-v3.pages.dev

View logs

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 ensures the bundler’s manifest-generation subprocess starts the Egg app in metadataOnly mode to avoid triggering normal shutdown/beforeClose logic during manifest generation, and adds a regression test that reproduces the failure mode.

Changes:

  • Start the manifest app with metadataOnly: true in generate-manifest.mjs.
  • Add a minimal, synthetic framework app repro to validate metadataOnly is passed and that shutdown hooks are skipped.
  • Assert that .egg/manifest.json is written and the “beforeClose” failure path is not hit.

Reviewed changes

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

File Description
tools/egg-bundler/src/scripts/generate-manifest.mjs Passes metadataOnly: true when starting the framework app for manifest generation.
tools/egg-bundler/test/generate-manifest.test.ts Adds a subprocess-based regression test for the metadataOnly startup behavior.

Comment thread tools/egg-bundler/test/generate-manifest.test.ts Outdated
@killagu killagu force-pushed the agent/egg-dev/84a193fb branch from 41b984c to ba3dd3b Compare May 2, 2026 04:26
Copilot AI review requested due to automatic review settings May 2, 2026 04:57
@killagu killagu force-pushed the agent/egg-dev/84a193fb branch from ba3dd3b to 43f924d Compare May 2, 2026 04:57
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

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

Comment thread tools/egg-bundler/src/scripts/generate-manifest.mjs
Comment thread tools/egg-bundler/test/generate-manifest.test.ts Outdated
Comment thread tools/egg-bundler/test/ManifestLoader.test.ts
@killagu killagu force-pushed the agent/egg-dev/84a193fb branch from 43f924d to 65e7513 Compare May 2, 2026 05:24
@killagu killagu merged commit fef9325 into next May 2, 2026
25 of 26 checks passed
@killagu killagu deleted the agent/egg-dev/84a193fb branch May 2, 2026 14:15
killagu added a commit that referenced this pull request May 2, 2026
## Summary

Fixes the current cnpmcore production bundle blockers seen on next after
#5910:

- generate worker entries with a portable framework import instead of an
absolute node_modules/egg path
- inline the bundle module loader registration so the generated worker
does not depend on @eggjs/utils
- provide runtime exports for EggAppConfig and Logger so non-import type
app code survives static export validation
- externalize packages that have missing optional peer dependencies, and
add the missing optional peers as externals, covering leoric optional
sql.js / mysql / sqlite3 paths

## Validation

- pnpm vitest run test/EntryGenerator.test.ts
test/ExternalsResolver.test.ts in tools/egg-bundler
- pnpm vitest run packages/egg/test/index.test.ts
- pnpm --filter egg run typecheck
- pnpm --filter @eggjs/egg-bundler run typecheck
- full pnpm run build was run during verification after the
implementation changes
- cnpmcore validation with local egg CLI/dist shim: node
../egg/tools/egg-bin/bin/run.js bundle --mode production --output
dist-bundle generated dist-bundle successfully

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Bundler now externalizes missing optional peer dependencies for more
correct builds.

* **Bug Fixes**
* Configuration and logger exports are exposed at runtime so apps start
reliably.

* **Chores**
  * Removed an unused dependency.
  * Standardized the bundler’s runtime module-loader approach.

* **Documentation**
* Updated bundling docs to reflect new module-loader and startup
behavior.

* **Tests**
* Added/updated tests covering externals resolution and generated
runtime hooks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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