mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
perf_hooks: fix PerformanceObserver gc crash
Signed-off-by: James M Snell <jasnell@gmail.com> Fixes: https://github.com/nodejs/node/issues/39548 PR-URL: https://github.com/nodejs/node/pull/39550 Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
1 parent
ba7368a1a9
commit
afabd145d1
2 files changed
+26
No files matched your search
@@ -132,6 +132,7 @@ function maybeDecrementObserverCounts(entryTypes) {
|
||||
if (observerType === NODE_PERFORMANCE_ENTRY_TYPE_GC &&
|
||||
observerCounts[observerType] === 0) {
|
||||
removeGarbageCollectionTracking();
|
||||
gcTrackingInstalled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
|
||||
// Refers to https://github.com/nodejs/node/issues/39548
|
||||
|
||||
// The test fails if this crashes. If it closes normally,
|
||||
// then all is good.
|
||||
|
||||
const {
|
||||
PerformanceObserver,
|
||||
} = require('perf_hooks');
|
||||
|
||||
// We don't actually care if the observer callback is called here.
|
||||
const gcObserver = new PerformanceObserver(() => {});
|
||||
|
||||
gcObserver.observe({ entryTypes: ['gc'] });
|
||||
|
||||
gcObserver.disconnect();
|
||||
|
||||
const gcObserver2 = new PerformanceObserver(() => {});
|
||||
|
||||
gcObserver2.observe({ entryTypes: ['gc'] });
|
||||
|
||||
gcObserver2.disconnect();
|
||||
Reference in new issue
Block a user