@@ -101,6 +101,13 @@ export function mainFn(meta, cb) {
101
101
process . on ( "unhandledRejection" , ( reason , promise ) => {
102
102
if ( _compasSentryExport ) {
103
103
_compasSentryExport . captureException ( reason ) ;
104
+ return _compasSentryExport . close ( 1000 ) . then ( ( ) => {
105
+ unhandled ( {
106
+ type : "unhandledRejection" ,
107
+ reason : AppError . format ( reason ) ,
108
+ promise,
109
+ } ) ;
110
+ } ) ;
104
111
}
105
112
106
113
unhandled ( {
@@ -113,6 +120,13 @@ export function mainFn(meta, cb) {
113
120
process . on ( "uncaughtException" , ( error , origin ) => {
114
121
if ( _compasSentryExport ) {
115
122
_compasSentryExport . captureException ( error ) ;
123
+ return _compasSentryExport . close ( 1000 ) . then ( ( ) => {
124
+ unhandled ( {
125
+ type : "uncaughtException" ,
126
+ error : AppError . format ( error ) ,
127
+ origin,
128
+ } ) ;
129
+ } ) ;
116
130
}
117
131
118
132
unhandled ( {
@@ -132,6 +146,13 @@ export function mainFn(meta, cb) {
132
146
Promise . resolve ( cb ( logger ) ) . catch ( ( e ) => {
133
147
if ( _compasSentryExport ) {
134
148
_compasSentryExport . captureException ( e ) ;
149
+ return _compasSentryExport . close ( 1000 ) . then ( ( ) => {
150
+ unhandled ( {
151
+ type : "error" ,
152
+ message : "Error caught from callback passed in `mainFn`" ,
153
+ error : AppError . format ( e ) ,
154
+ } ) ;
155
+ } ) ;
135
156
}
136
157
137
158
unhandled ( {
0 commit comments