Commit 5d90728
feat(core,egg): add V8 startup snapshot lifecycle hooks and APIs
Add snapshotWillSerialize/snapshotDidDeserialize lifecycle hooks and
snapshot-safe initialization patterns for V8 startup snapshot support.
## core changes
- Add `snapshotWillSerialize()` / `snapshotDidDeserialize()` to ILifecycleBoot
- triggerSnapshotWillSerialize: reverse order (LIFO, like beforeClose)
- triggerSnapshotDidDeserialize: forward order (FIFO), resumes lifecycle from configDidLoad
- Expose trigger methods on EggCore for build scripts
## egg changes
- Agent keepalive timer moved to configDidLoad via object literal boot hook
- Messenger/logger/unhandledRejection cleanup via protected snapshotWillSerialize/snapshotDidDeserialize methods
- Zero `if (this.options.snapshot)` guards — all handled by lifecycle structure
- New APIs: startEggForSnapshot(), buildSnapshot(), restoreSnapshot()
- loadFinished promise for snapshot build scripts
## Tests
- 16 core snapshot tests (hook ordering, async, error handling, lifecycle resume)
- 10 egg snapshot tests (agent keepalive, messenger, logger, unhandledRejection, APIs)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 21b1a71 commit 5d90728
File tree
10 files changed
+1015
-5
lines changed- packages
- core
- src
- test
- egg
- src
- lib
- test
- __snapshots__
10 files changed
+1015
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
415 | 433 | | |
416 | 434 | | |
417 | 435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
| |||
380 | 397 | | |
381 | 398 | | |
382 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
383 | 473 | | |
384 | 474 | | |
385 | 475 | | |
| |||
0 commit comments