@middy/cloudwatch-metrics 7.2.1 → 7.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +8 -5
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -21,12 +21,15 @@ const cloudwatchMetricsMiddleware = (opts = {}) => {
21
21
  Object.assign(request.context, { metrics });
22
22
  };
23
23
 
24
- const cloudwatchMetricsAfter = async (request) => {
25
- await request.context.metrics?.flush();
26
- };
27
- const cloudwatchMetricsOnError = async (request) => {
28
- await request.context.metrics?.flush();
24
+ const flushMetrics = async (request) => {
25
+ try {
26
+ await request.context.metrics?.flush();
27
+ } catch {
28
+ // Swallow flush errors to prevent metrics from crashing the handler
29
+ }
29
30
  };
31
+ const cloudwatchMetricsAfter = flushMetrics;
32
+ const cloudwatchMetricsOnError = flushMetrics;
30
33
 
31
34
  return {
32
35
  before: cloudwatchMetricsBefore,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/cloudwatch-metrics",
3
- "version": "7.2.1",
3
+ "version": "7.2.3",
4
4
  "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -71,7 +71,7 @@
71
71
  "aws-embedded-metrics": "4.2.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@middy/core": "7.2.1",
74
+ "@middy/core": "7.2.3",
75
75
  "@types/aws-lambda": "^8.0.0",
76
76
  "@types/node": "^22.0.0"
77
77
  }