| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a45bf2f commit b3352cf
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -325,6 +325,7 @@ function createRepl(inspector) { | |||
| 325 | 325 | const history = { control: [], debug: [] }; | |
| 326 | 326 | const watchedExpressions = []; | |
| 327 | 327 | const knownBreakpoints = []; | |
| 328 | + let heapSnapshotPromise = null; | ||
| 328 | 329 | let pauseOnExceptionState = 'none'; | |
| 329 | 330 | let lastCommand; | |
| 330 | 331 | ||
@@ -961,7 +962,13 @@ function createRepl(inspector) { | |||
| 961 | 962 | }, | |
| 962 | 963 | ||
| 963 | 964 | takeHeapSnapshot(filename = 'node.heapsnapshot') { | |
| 964 | - return new Promise((resolve, reject) => { | ||
| 965 | + if (heapSnapshotPromise) { | ||
| 966 | + print( | ||
| 967 | + 'Cannot take heap snapshot because another snapshot is in progress.' | ||
| 968 | + ); | ||
| 969 | + return heapSnapshotPromise; | ||
| 970 | + } | ||
| 971 | + heapSnapshotPromise = new Promise((resolve, reject) => { | ||
| 965 | 972 | const absoluteFile = Path.resolve(filename); | |
| 966 | 973 | const writer = FS.createWriteStream(absoluteFile); | |
| 967 | 974 | let sizeWritten = 0; | |
@@ -983,6 +990,7 @@ function createRepl(inspector) { | |||
| 983 | 990 | writer.end(() => { | |
| 984 | 991 | teardown(); | |
| 985 | 992 | print(`Wrote snapshot: ${absoluteFile}`); | |
| 993 | + heapSnapshotPromise = null; | ||
| 986 | 994 | resolve(); | |
| 987 | 995 | }); | |
| 988 | 996 | } | |
@@ -1006,6 +1014,7 @@ function createRepl(inspector) { | |||
| 1006 | 1014 | HeapProfiler.takeHeapSnapshot({ reportProgress: true }), | |
| 1007 | 1015 | onResolve, onReject); | |
| 1008 | 1016 | }); | |
| 1017 | + return heapSnapshotPromise; | ||
| 1009 | 1018 | }, | |
| 1010 | 1019 | ||
| 1011 | 1020 | get watchers() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,10 @@ const filename = 'node.heapsnapshot'; | |||
| 32 | 32 | .then(() => cli.waitForPrompt()) | |
| 33 | 33 | .then(() => cli.command('takeHeapSnapshot()')) | |
| 34 | 34 | .then(() => JSON.parse(readFileSync(filename, 'utf8'))) | |
| 35 | + // Check that two simultaneous snapshots don't step all over each other. | ||
| 36 | + // Refs: https://github.com/nodejs/node/issues/39555 | ||
| 37 | + .then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()')) | ||
| 38 | + .then(() => JSON.parse(readFileSync(filename, 'utf8'))) | ||
| 35 | 39 | .then(() => cli.quit()) | |
| 36 | 40 | .then(null, onFatal); | |
| 37 | 41 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments