test: fix flaky test-perf-hooks-histogram

Make sure the histogram containing event loop delay info is posted only
when at least one datapoint is collected.

Fixes: https://github.com/nodejs/node/issues/43503

PR-URL: https://github.com/nodejs/node/pull/43567
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Santiago Gimeno authored and Michaël Zasso committed 2022-07-12 07:41:48 +02:00
1 parent 508cbbcbf9
commit 2adf4e7727
1 file changed
+6 -1
+6 -1
View File
@@ -89,7 +89,12 @@ const { inspect } = require('util');
strictEqual(data.enable, undefined);
mc.port1.close();
});
setTimeout(() => mc.port2.postMessage(e), 100);
const interval = setInterval(() => {
if (e.count > 0) {
clearInterval(interval);
mc.port2.postMessage(e);
}
}, 50);
}
{