Skip to content

docs(snapshot): add V8 snapshot troubleshooting guide#6010

Merged
killagu merged 1 commit into
eggjs:nextfrom
killagu:docs/snapshot-troubleshooting
Jun 28, 2026
Merged

docs(snapshot): add V8 snapshot troubleshooting guide#6010
killagu merged 1 commit into
eggjs:nextfrom
killagu:docs/snapshot-troubleshooting

Conversation

@killagu

@killagu killagu commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Motivation

Building a V8 startup snapshot serializes the whole heap, so any dependency that
opens a socket, starts a timer, or initializes a native binding at
module-evaluation time can make the blob fail to build — or build and then crash
on restore. There was no guide for finding which module is responsible or how to
fix it.

What

New dedicated page advanced/snapshot-troubleshooting.md (EN + zh-CN):

  • The serializability rule — what cannot survive the round-trip (native
    bindings / libuv handles / lazy web-global getters) and when a dependency
    trips it.
  • Failure surfaces — build-time vs restore-time, with the exact error
    strings each emits (killed by signal SIGSEGV, no blob was written,
    Check failed: current == end_slot_index, Aop Advice not found,
    Cannot find module, …).
  • Find the offending moduleNODE_DEBUG namespaces, a clean
    NODE_OPTIONS, --dry-run, --skip-bundle bisecting, --force-external
    confirmation.
  • Fixes--force-external, egg.snapshot.lazyModules, the snapshot
    lifecycle hooks, deferring work out of module scope, avoiding the web globals.
  • Failure modes in detail (tegg @Advice filePath, the lazy-external member
    proxy, runtime-asset ENOENT) and a configuration reference table.

Also documents the previously-undocumented egg.snapshot.lazyModules config in
advanced/snapshot.md, cross-links the new page from it, and wires the page into
the English and Chinese advanced sidebars.

Docs-only; no runtime code change. Builds on the snapshot feature already on
next (#5998 / #5999 / #6001 / #6003).

Test evidence

  • vitepress build site passes clean — VitePress's dead-link/anchor check is
    green, so both new pages render and every cross-file and in-page anchor
    resolves (the two detail headings use explicit ASCII {#…} ids because the
    VitePress slugifier retains CJK + fullwidth 「」).
  • Every technical claim was adversarially verified against the
    egg-bundler / egg-bin / egg-scripts source — exact error strings, flag
    names, debug namespaces, and the default lazy-module set.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a new Snapshot Troubleshooting guide in English and Chinese, covering common build and restore failure symptoms, how to diagnose them, and recommended fixes.
    • Expanded the Snapshot guide with guidance on configuring additional lazy-loaded modules, plus clearer troubleshooting links.
    • Updated the sidebar navigation to include the new troubleshooting page in both languages.

Add a dedicated troubleshooting page (EN + zh-CN) covering how to diagnose
which module makes a V8 startup snapshot fail to build or restore, and how to
fix it:

- the serializability rule (native bindings / libuv handles / lazy web-global
  getters) and when a dependency trips it at module-evaluation time
- build-time vs restore-time failure signatures, with the exact error strings
  emitted by egg-bin / the generated worker entry / egg-scripts
- diagnosis: NODE_DEBUG namespaces, a clean NODE_OPTIONS, --dry-run,
  --skip-bundle bisecting, --force-external confirmation
- fixes: --force-external, egg.snapshot.lazyModules, the snapshot lifecycle
  hooks, deferring work out of module scope, avoiding the web globals
- detailed failure modes (tegg @advice filePath, the lazy-external member
  proxy, runtime-asset ENOENT) and a configuration reference

Also document the previously-undocumented egg.snapshot.lazyModules config in
advanced/snapshot.md, cross-link the new page from it, and wire the page into
the English and Chinese advanced sidebars.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 28, 2026 01:50

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e87cde32-a0a7-4fcd-92b1-f167d640f9de

📥 Commits

Reviewing files that changed from the base of the PR and between 6900383 and d986fb0.

📒 Files selected for processing (5)
  • site/.vitepress/config.mts
  • site/docs/advanced/snapshot-troubleshooting.md
  • site/docs/advanced/snapshot.md
  • site/docs/zh-CN/advanced/snapshot-troubleshooting.md
  • site/docs/zh-CN/advanced/snapshot.md

📝 Walkthrough

Walkthrough

Adds new "Snapshot Troubleshooting" documentation pages in English and Chinese, covering build/restore failure detection, diagnosis workflows, fix strategies, failure-mode details, and a configuration reference. Updates existing snapshot.md in both locales with lazyModules config examples, expanded web-global stub lists, and Troubleshooting sections. Registers sidebar entries for both locales.

Changes

Snapshot Troubleshooting Documentation

Layer / File(s) Summary
Sidebar registration
site/.vitepress/config.mts
Adds "Snapshot Troubleshooting" / "快照故障排查" entries to the EN and ZH Advanced sidebar sections.
Updates to existing snapshot docs
site/docs/advanced/snapshot.md, site/docs/zh-CN/advanced/snapshot.md
Adds egg.snapshot.lazyModules config explanation and JSON example, expands the list of web globals stubbed after restore, and introduces a Troubleshooting section linking to the new pages.
New EN troubleshooting page
site/docs/advanced/snapshot-troubleshooting.md
386-line guide covering serialization constraints, build-time vs restore-time failure signatures, step-by-step diagnosis (clean env, NODE_DEBUG, --skip-bundle bisect, --force-external), ordered fixes (lazyModules, lifecycle hooks, deferred init), detailed failure modes, and a configuration reference table.
New ZH troubleshooting page
site/docs/zh-CN/advanced/snapshot-troubleshooting.md
Chinese equivalent of the EN troubleshooting guide, covering the same content in 349 lines.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • eggjs/egg#5856: Implements the snapshot lifecycle APIs (snapshotWillSerialize/snapshotDidDeserialize) and build/restore functionality that this troubleshooting guide documents.
  • eggjs/egg#5891: Previous expansion of site/docs/advanced/snapshot.md and related zh-CN snapshot pages that this PR extends.

Suggested reviewers

  • jerryliang64

🐇 A snapshot must freeze,
No handles or natives, please!
Debug with NODE_DEBUG,
Force external — that's the clue,
Hooks restore what snapshots tease! 🌸

🚥 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: adding a V8 snapshot troubleshooting guide in docs.
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.
✨ 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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a comprehensive troubleshooting guide for V8 Startup Snapshots in both English and Chinese, detailing build-time and restore-time failure modes, diagnostic steps, and common fixes. It also updates the VitePress sidebar configuration to include these new pages and enhances the main snapshot documentation with references to the troubleshooting guide, additional details on configuring lazy modules, and an expanded list of web globals replaced by stubs. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.94%. Comparing base (6900383) to head (d986fb0).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #6010      +/-   ##
==========================================
- Coverage   81.95%   81.94%   -0.01%     
==========================================
  Files         677      677              
  Lines       20651    20651              
  Branches     4099     4099              
==========================================
- Hits        16924    16922       -2     
- Misses       3214     3215       +1     
- Partials      513      514       +1     

☔ View full report in Codecov by Harness.
📢 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.

@killagu killagu merged commit ff17536 into eggjs:next Jun 28, 2026
19 of 21 checks passed
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