Skip to content

Commit

Permalink
Reduce scope of async hook
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Jan 16, 2024
1 parent c82b38e commit 6508bbf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
8 changes: 1 addition & 7 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95407,23 +95407,17 @@ const core = __importStar(__nccwpck_require__(2186));
const setupGradle = __importStar(__nccwpck_require__(8652));
const async_hooks = __importStar(__nccwpck_require__(852));
const asyncHook = async_hooks.createHook({
init(asyncId, type, _triggerAsyncId, _resource) {
core.info(`Async operation started: asyncId ${asyncId}, type ${type}`);
},
before(asyncId) {
core.info(`Before async operation: asyncId ${asyncId}`);
},
after(asyncId) {
core.info(`After async operation: asyncId ${asyncId}`);
},
destroy(asyncId) {
core.info(`Async operation destroyed: asyncId ${asyncId}`);
}
});
asyncHook.enable();
process.on('uncaughtException', e => handleFailure(e));
function run() {
return __awaiter(this, void 0, void 0, function* () {
asyncHook.enable();
try {
yield setupGradle.complete();
core.info('Finished setupGradle.complete()');
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import * as setupGradle from './setup-gradle'
import * as async_hooks from 'async_hooks'

const asyncHook = async_hooks.createHook({
init(asyncId, type, _triggerAsyncId, _resource) {
core.info(`Async operation started: asyncId ${asyncId}, type ${type}`)
},
before(asyncId) {
core.info(`Before async operation: asyncId ${asyncId}`)
},
after(asyncId) {
core.info(`After async operation: asyncId ${asyncId}`)
},
Expand All @@ -17,8 +11,6 @@ const asyncHook = async_hooks.createHook({
}
})

asyncHook.enable()

// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
// throw an uncaught exception. Instead of failing this action, just warn.
Expand All @@ -28,6 +20,8 @@ process.on('uncaughtException', e => handleFailure(e))
* The post-execution entry point for the action, called by Github Actions after completing all steps for the Job.
*/
export async function run(): Promise<void> {
asyncHook.enable()

try {
await setupGradle.complete()
core.info('Finished setupGradle.complete()')
Expand Down

0 comments on commit 6508bbf

Please sign in to comment.