File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed
tests/serverless-plugins-integration Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -68,18 +68,23 @@ function processS3Event(output) {
68
68
if ( ! output . includes ( 'Records' ) || ! output . includes ( 'eventSource":"minio:s3"' ) ) return ;
69
69
70
70
try {
71
- const jsonStart = output . indexOf ( '{' ) ;
72
- if ( jsonStart < 0 ) return ;
73
-
74
- const jsonEnd = output . lastIndexOf ( '}' ) ;
75
- if ( jsonEnd <= jsonStart ) return ;
76
-
77
- const jsonStr = output . slice ( jsonStart , jsonEnd + 1 ) ;
78
-
79
- const eventData = JSON . parse ( jsonStr ) ;
80
- if ( ! eventData || ! eventData . Records || eventData . Records . length === 0 ) return ;
81
- const eventId = `${ eventData . Records [ 0 ] . s3 . bucket . name } -${ eventData . Records [ 0 ] . s3 . object . key } ` ;
82
- incrementlambdaCallCounter ( eventId ) ;
71
+ output
72
+ . split ( '\n' )
73
+ . filter ( line => line . includes ( 'Records' ) && line . includes ( 'eventSource":"minio:s3"' ) )
74
+ . forEach ( line => {
75
+ const jsonStart = line . indexOf ( '{' ) ;
76
+ if ( jsonStart < 0 ) return ;
77
+
78
+ const jsonEnd = line . lastIndexOf ( '}' ) ;
79
+ if ( jsonEnd <= jsonStart ) return ;
80
+
81
+ const jsonStr = line . slice ( jsonStart , jsonEnd + 1 ) ;
82
+
83
+ const eventData = JSON . parse ( jsonStr ) ;
84
+ if ( ! eventData || ! eventData . Records || eventData . Records . length === 0 ) return ;
85
+ const eventId = `${ eventData . Records [ 0 ] . s3 . bucket . name } -${ eventData . Records [ 0 ] . s3 . object . key } ` ;
86
+ incrementlambdaCallCounter ( eventId ) ;
87
+ } ) ;
83
88
} catch ( err ) {
84
89
console . error ( 'Error in processS3Event:' , { err, output} ) ;
85
90
}
You can’t perform that action at this time.
0 commit comments