Skip to content

Commit 07b54b9

Browse files
committed
fix: event/sentry flush, event status code
Signed-off-by: Sam Gammon <[email protected]>
1 parent 9808ca3 commit 07b54b9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/diagnostics.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async function transmitEvent(event: ActionEvent<any>): Promise<void> {
143143
encoded,
144144
headers
145145
)
146-
if (res.message.statusCode !== 200 && res.message.statusCode !== 204) {
146+
if (res.message.statusCode !== 200 && res.message.statusCode !== 202) {
147147
core.debug(`Event transmission failed: ${res.message.statusMessage}`)
148148
} else {
149149
core.debug(`Event transmission completed (ID: ${event.uuid})`)
@@ -209,6 +209,14 @@ export async function error(err: Error | unknown, fatal = true): Promise<void> {
209209
fatal
210210
})
211211
Sentry.captureException(err)
212-
const flush = Sentry.flush()
213-
await Promise.all([req, flush])
212+
await Promise.all([req])
213+
}
214+
215+
/**
216+
* Exit hook for making sure Sentry finishes reporting.
217+
*/
218+
export async function onExit(): Promise<void> {
219+
Sentry.close(2000).then(function () {
220+
process.exit()
221+
})
214222
}

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from './agent'
1818

1919
import {
20+
onExit,
2021
ActionEventType,
2122
error as sendError,
2223
event as sendEvent
@@ -589,6 +590,8 @@ export async function entry(options?: Partial<Options>): Promise<void> {
589590
core.warning(
590591
'Buildless failed to install; this build may not be accelerated. Please see CI logs for more information.'
591592
)
593+
} finally {
594+
await onExit()
592595
}
593596
}
594597

@@ -607,5 +610,7 @@ export async function cleanup(options?: Partial<Options>): Promise<void> {
607610
core.notice(
608611
'Cleanup stage for the Buildless action failed. Please see CI logs for more information.'
609612
)
613+
} finally {
614+
await onExit()
610615
}
611616
}

0 commit comments

Comments
 (0)