CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-workerpool

Offload tasks to a pool of workers on node.js and in the browser

Overall
score

95%

Overview
Eval results
Files

task.mdevals/scenario-10/

Resilient Task Processor

Build a task processing system that can handle worker crashes gracefully and continue processing remaining tasks without losing track of failures.

Capabilities

Worker Pool Management

The system must create a worker pool that executes computational tasks in parallel workers.

Crash Detection and Handling

  • The system detects when a worker crashes during task execution @test
  • When a worker crashes, the corresponding task promise is rejected with an error @test
  • The pool continues functioning with remaining healthy workers after a crash @test

Task Execution with Crash Scenarios

  • Tasks that complete successfully before any crash return their results correctly @test
  • Multiple tasks can be submitted, and the system tracks which succeed and which fail due to crashes @test

Implementation

@generates

The implementation should:

  1. Create a worker pool configured to execute tasks
  2. Provide a method to submit tasks to the pool
  3. Handle scenarios where workers crash during execution
  4. Ensure that crashed workers are properly cleaned up
  5. Return results for successful tasks and errors for failed tasks

The worker script should be created at ./src/crash-worker.js and should:

  • Accept a task configuration that includes whether it should crash
  • Simulate work by using a small delay
  • Intentionally crash (e.g., call a non-existent function) when instructed
  • Return a success result when not instructed to crash

API

/**
 * Creates a resilient task processor that handles worker crashes
 *
 * @returns {Object} An object with methods to submit tasks and clean up
 */
function createResilientProcessor() {
  // Returns object with:
  // - submitTask(shouldCrash): Promise that resolves with result or rejects on crash
  // - cleanup(): Promise that cleans up the worker pool
}

module.exports = { createResilientProcessor };

Dependencies { .dependencies }

workerpool { .dependency }

Provides worker pool functionality with crash recovery capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-workerpool

tile.json