The cancel message containing the target task ID.
Collection of currently active task IDs.
export function handleCancel(
message: CancelMessage,
activeTasks: Set<string>,
): void {
const { taskId } = message.payload;
console.debug(`[Worker] ⏹️ Cancel requested for task ${taskId}`);
const csvState = csvParserStates.get(taskId);
const hadCSVTask = !!csvState;
// Ensure local tracking and CSV parser state are cleared for the cancelled task
activeTasks.delete(taskId);
csvParserStates.delete(taskId);
if (hadCSVTask) {
self.postMessage({
type: "CSV_CANCELLED",
payload: { taskId },
});
}
}
Handles cancellation of worker tasks and notifies CSV parsing when applicable.