From ede5c648f7667ea05dcdb5c9f1e7f8c1d75da922 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 20 Sep 2023 10:29:20 +0100 Subject: [PATCH] fix: emit copy of metrics (#1) To prevent observers changing internal state, emit a copy of the metrics. --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4e44d70..d44ae54 100644 --- a/src/index.ts +++ b/src/index.ts @@ -158,7 +158,7 @@ class SimpleMetrics implements Metrics, Startable { } } - this.onMetrics(output) + this.onMetrics(JSON.parse(JSON.stringify(output))) }) .catch(err => { log.error('could not invoke onMetrics callback', err)