Skip to content

Commit

Permalink
test: fix flaky test-otlp-metrics.mjs
Browse files Browse the repository at this point in the history
Avoid calling `child.send('exit')` multiple times as it might trigger an
`EPIPE` error.
  • Loading branch information
santigimeno committed Jun 17, 2024
1 parent 418669b commit a3ee043
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/agents/test-otlp-metrics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,14 @@ if (process.argv[2] === 'child') {

async function runTest(getEnv) {
return new Promise((resolve, reject) => {
let exitCalled = false;
const otlpServer = new OTLPServer();
otlpServer.start(mustSucceed(async (port) => {
otlpServer.on('metrics', mustCallAtLeast((metrics) => {
checkMetrics(metrics, context);
if (context.state === State.ThreadMetrics) {
if (context.state === State.ThreadMetrics && !exitCalled) {
child.send('exit');
exitCalled = true;
}
}, 1));

Expand Down

0 comments on commit a3ee043

Please sign in to comment.