Node.js - Debugging and Profiling
You wrote this code to save a heap snapshot but it never finishes and the file is empty:
import { writeFileSync } from 'fs';
import { getHeapSnapshot } from 'v8';
const snapshotStream = getHeapSnapshot();
snapshotStream.on('data', chunk => {
writeFileSync('heap.heapsnapshot', chunk);
});
console.log('Snapshot saved');
What is the main problem?