Commit 09adea9
Align Flow lib defs for Node.js v8 module with v24 (#55225)
Summary:
Pull Request resolved: #55225
This is an AI-assisted change to align the Flow definitions for the `v8` module with the Node.js docs as at v24.
**New v18+ Features:**
1. **Heap Snapshot Near Limit** (v18.10.0) - Automatic snapshot generation
- Added `setHeapSnapshotNearHeapLimit(limit: number): void` function
- Generates heap snapshots automatically when heap usage reaches specified limit
- Useful for debugging memory issues and OOM scenarios
- https://nodejs.org/api/v8.html#v8setheapsnapshotnearhea plimit
2. **GCProfiler Class** (v19.6.0, v18.15.0) - Garbage collection profiling
- Added `GCProfiler` class for detailed GC statistics collection
- `start()` method begins profiling session
- `stop()` method returns `GCProfilerResult` with detailed statistics
- Includes before/after heap statistics for each GC event
- https://nodejs.org/api/v8.html#class-v8gcprofiler
**New v20+ Features:**
3. **Query Objects** (v20.13.0) - Object instance tracking
- Added `queryObjects(ctor, options?)` function with two overloads
- Similar to Chrome DevTools console API
- Searches for objects matching a constructor on prototype chain
- Two formats: `'count'` (returns number) or `'summary'` (returns string array)
- Useful for memory leak regression tests
- https://nodejs.org/api/v8.html#v8queryobjectsctor-options
**New v22+ Features:**
4. **C++ Heap Statistics** (v22.15.0) - cppgc heap monitoring
- Added `getCppHeapStatistics(detailLevel?)` function
- Returns C++ heap statistics from cppgc
- Two detail levels: `'brief'` (top-level stats) or `'detailed'` (includes space/page breakdown)
- https://nodejs.org/api/v8.html#v8getcppheapstatisticsdetaillevel
5. **String Representation Check** (v23.10.0, backported to v22.15.0)
- Added `isStringOneByteRepresentation(content: string): boolean` function
- Checks if string uses Latin-1/ISO-8859-1 encoding (single byte per character)
- Useful for optimizing string serialization
- https://nodejs.org/api/v8.html#v8isstringonebyterepresentationvalue
**Type System Improvements:**
6. **Complete Type Definitions** - Added missing fields and proper types:
- `DoesZapCodeSpaceFlag` type alias (0 | 1) for `does_zap_garbage`
- `HeapCodeStatistics` - Added `cpu_profiler_metadata_size` field
- `HeapInfo` (renamed from `HeapStatistics`) - Added 3 missing fields:
- `total_global_handles_size` (v13.3.0)
- `used_global_handles_size` (v13.3.0)
- `external_memory` (v13.3.0)
- `HeapSpaceInfo` (renamed from `HeapSpaceStatistics`) - Removed spread operator
- `HeapSnapshotOptions` (new) - Options for heap snapshot generation:
- `exposeInternals?: boolean` - Expose internals in snapshot
- `exposeNumericValues?: boolean` - Expose numeric values
- `HeapStatistics` (camelCase) - For GCProfiler, complete with all 11 fields
- `HeapSpaceStatistics` (camelCase) - For GCProfiler, complete with all 5 fields
- `GCProfilerResult` - Complete result type with version, timing, and statistics array
- https://nodejs.org/api/v8.html#v8getheapstatistics
7. **Enhanced Function Signatures**:
- `getHeapSnapshot(options?)` - Added optional `HeapSnapshotOptions` parameter
- `writeHeapSnapshot(fileName?, options?)` - Added optional `HeapSnapshotOptions` parameter
- `getHeapStatistics()` - Changed return type from `HeapStatistics` to `HeapInfo`
- `getHeapSpaceStatistics()` - Changed return type to `Array<HeapSpaceInfo>`
- https://nodejs.org/api/v8.html#v8getheapsnapshotoptions
8. **Coverage Functions** - For type profile analysis:
- `takeCoverage(): void` (v15.1.0) - Starts capturing V8 type profile
- `stopCoverage(): void` (v15.1.0) - Stops capturing V8 type profile
- https://nodejs.org/api/v8.html#v8takecoverage
9. **Serialization Documentation**:
- Added `since v8.0.0` tags to all serialization classes and functions
- Improved class documentation for `Serializer`, `Deserializer`, `DefaultSerializer`, `DefaultDeserializer`
- https://nodejs.org/api/v8.html#serialization-api
**References:**
- Node.js v8 module docs: https://nodejs.org/api/v8.html
- Heap statistics: https://nodejs.org/api/v8.html#v8getheapstatistics
- GC profiling: https://nodejs.org/api/v8.html#class-v8gcprofiler
- Query objects: https://nodejs.org/api/v8.html#v8queryobjectsctor-options
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D90762740
fbshipit-source-id: 41581da6af6e62198c94e336740241b7983d44861 parent 6f698ab commit 09adea9
1 file changed
Lines changed: 186 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4975 | 4975 | | |
4976 | 4976 | | |
4977 | 4977 | | |
4978 | | - | |
4979 | | - | |
4980 | | - | |
4981 | | - | |
4982 | | - | |
4983 | | - | |
| 4978 | + | |
| 4979 | + | |
4984 | 4980 | | |
4985 | | - | |
4986 | | - | |
4987 | | - | |
4988 | | - | |
4989 | | - | |
4990 | | - | |
4991 | | - | |
4992 | | - | |
4993 | | - | |
4994 | | - | |
4995 | | - | |
4996 | | - | |
4997 | | - | |
4998 | | - | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
4999 | 4987 | | |
5000 | | - | |
5001 | | - | |
5002 | | - | |
5003 | | - | |
5004 | | - | |
5005 | | - | |
5006 | | - | |
5007 | | - | |
| 4988 | + | |
| 4989 | + | |
| 4990 | + | |
| 4991 | + | |
| 4992 | + | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
| 5005 | + | |
| 5006 | + | |
| 5007 | + | |
| 5008 | + | |
| 5009 | + | |
| 5010 | + | |
| 5011 | + | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
| 5027 | + | |
| 5028 | + | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
| 5037 | + | |
| 5038 | + | |
| 5039 | + | |
| 5040 | + | |
| 5041 | + | |
| 5042 | + | |
| 5043 | + | |
| 5044 | + | |
| 5045 | + | |
| 5046 | + | |
| 5047 | + | |
| 5048 | + | |
| 5049 | + | |
| 5050 | + | |
| 5051 | + | |
| 5052 | + | |
| 5053 | + | |
| 5054 | + | |
| 5055 | + | |
| 5056 | + | |
| 5057 | + | |
5008 | 5058 | | |
5009 | | - | |
5010 | | - | |
5011 | | - | |
5012 | 5059 | | |
5013 | | - | |
5014 | | - | |
| 5060 | + | |
| 5061 | + | |
| 5062 | + | |
5015 | 5063 | | |
5016 | 5064 | | |
5017 | 5065 | | |
5018 | 5066 | | |
5019 | | - | |
5020 | | - | |
5021 | | - | |
5022 | | - | |
5023 | | - | |
5024 | | - | |
| 5067 | + | |
5025 | 5068 | | |
5026 | | - | |
| 5069 | + | |
5027 | 5070 | | |
5028 | 5071 | | |
5029 | | - | |
5030 | | - | |
5031 | | - | |
5032 | | - | |
5033 | | - | |
5034 | | - | |
5035 | | - | |
| 5072 | + | |
5036 | 5073 | | |
5037 | | - | |
| 5074 | + | |
5038 | 5075 | | |
5039 | | - | |
| 5076 | + | |
| 5077 | + | |
| 5078 | + | |
| 5079 | + | |
5040 | 5080 | | |
5041 | | - | |
5042 | | - | |
| 5081 | + | |
| 5082 | + | |
| 5083 | + | |
| 5084 | + | |
| 5085 | + | |
| 5086 | + | |
| 5087 | + | |
| 5088 | + | |
| 5089 | + | |
| 5090 | + | |
| 5091 | + | |
| 5092 | + | |
| 5093 | + | |
| 5094 | + | |
| 5095 | + | |
| 5096 | + | |
| 5097 | + | |
| 5098 | + | |
| 5099 | + | |
| 5100 | + | |
| 5101 | + | |
| 5102 | + | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
5043 | 5109 | | |
5044 | 5110 | | |
| 5111 | + | |
| 5112 | + | |
| 5113 | + | |
| 5114 | + | |
| 5115 | + | |
| 5116 | + | |
| 5117 | + | |
| 5118 | + | |
| 5119 | + | |
| 5120 | + | |
| 5121 | + | |
| 5122 | + | |
| 5123 | + | |
| 5124 | + | |
| 5125 | + | |
| 5126 | + | |
| 5127 | + | |
| 5128 | + | |
| 5129 | + | |
| 5130 | + | |
| 5131 | + | |
| 5132 | + | |
| 5133 | + | |
| 5134 | + | |
| 5135 | + | |
| 5136 | + | |
| 5137 | + | |
| 5138 | + | |
| 5139 | + | |
| 5140 | + | |
| 5141 | + | |
| 5142 | + | |
| 5143 | + | |
| 5144 | + | |
| 5145 | + | |
| 5146 | + | |
| 5147 | + | |
| 5148 | + | |
| 5149 | + | |
| 5150 | + | |
| 5151 | + | |
| 5152 | + | |
| 5153 | + | |
| 5154 | + | |
| 5155 | + | |
| 5156 | + | |
| 5157 | + | |
5045 | 5158 | | |
5046 | 5159 | | |
5047 | 5160 | | |
| |||
5163 | 5276 | | |
5164 | 5277 | | |
5165 | 5278 | | |
| 5279 | + | |
| 5280 | + | |
| 5281 | + | |
| 5282 | + | |
| 5283 | + | |
| 5284 | + | |
| 5285 | + | |
| 5286 | + | |
| 5287 | + | |
| 5288 | + | |
| 5289 | + | |
| 5290 | + | |
| 5291 | + | |
| 5292 | + | |
| 5293 | + | |
| 5294 | + | |
| 5295 | + | |
5166 | 5296 | | |
5167 | 5297 | | |
5168 | 5298 | | |
| |||
5600 | 5730 | | |
5601 | 5731 | | |
5602 | 5732 | | |
| 5733 | + | |
| 5734 | + | |
| 5735 | + | |
| 5736 | + | |
| 5737 | + | |
5603 | 5738 | | |
5604 | 5739 | | |
5605 | 5740 | | |
| |||
0 commit comments