run-command icon indicating copy to clipboard operation
run-command copied to clipboard

Matlab process orphaned when workflow is cancelled

Open rebeccamccabe opened this issue 5 months ago • 5 comments

My matlab process hangs (possibly due to a similar bug as described here https://github.com/matlab-actions/setup-matlab/issues/154, but the reason shouldn't be relevant for this issue), causing the run-command action to run indefinitely.

When I cancel the CI workflow from github, the run-command action does not pass on the cancellation signal, leaving the matlab process orphaned. Since I use a self hosted runner, this prevents the next queued workflow from running on the runner, even when the action has reached its 6 hour timeout and github shows it as cancelled. I would want this action to kill the matlab process when it receives the cancel signal from github.

An AI tool suggested that modifying index.ts to the following would work:

const execOpts = {
        // env: {...process.env, MW_BATCH_LICENSING_ONLINE:'true'}  // Disabled while we work out online licensing kinks
    };

becomes

const controller = new AbortController();
const execOpts = {
        signal: controller.signal,   // 👈 this enables automatic kill on workflow cancel
        // env: {...process.env, MW_BATCH_LICENSING_ONLINE:'true'}  // Disabled while we work out online licensing kinks
    };

but I am not sufficiently familiar with how to build github actions that I feel comfortable testing that change.

rebeccamccabe avatar Aug 25 '25 23:08 rebeccamccabe