mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
fix: improve abort handling in spawnJSONLProcess
- Added immediate invocation of abort handler if the abort signal is already triggered, ensuring proper cleanup. - Updated test to use setImmediate for aborting, allowing the generator to start processing before the abort is called, enhancing reliability.
This commit is contained in:
@@ -97,7 +97,12 @@ export async function* spawnJSONLProcess(options: SubprocessOptions): AsyncGener
|
||||
}
|
||||
childProcess.kill('SIGTERM');
|
||||
};
|
||||
abortController.signal.addEventListener('abort', abortHandler);
|
||||
// Check if already aborted, if so call handler immediately
|
||||
if (abortController.signal.aborted) {
|
||||
abortHandler();
|
||||
} else {
|
||||
abortController.signal.addEventListener('abort', abortHandler);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to clean up abort listener
|
||||
|
||||
Reference in New Issue
Block a user