Skip to content
Astera Technology

Test whether parent timeout stops its child

Observe a controlled local worker after a real parent timer fires.

Download complete case notes and answer keys ↓

Set the decision and its input

The bounded demonstration uses a real5ms parent timeout and a live local Worker. Parent-only timeout leaves the child running at the observation point. The supplied cancel-child rule requires awaiting Worker termination; the repaired observation then shows childExited=true.

Filled local test worksheet
CaseInput JSON
Base test{"timeoutMs":5,"cancelChild":true}
Download editable CSV ↓

Run the supplied comparison

The worker sends ready before the timer starts. Remaining workers are cleaned up after observations, so the programme leaves no background task. The short test is not a five-minute production deadline guarantee.

Faulty and required outputs
PathOutput JSON
Faulty path{"parent":"timed-out","childExited":false}
Required path{"parent":"timed-out","childExited":true}
Download editable CSV ↓
Complete local Node24.14.1 programme
import assert from 'node:assert/strict';
const smallWhole=(x,max)=>Number.isSafeInteger(x)&&x>=0&&x<=max;
import {Worker} from 'node:worker_threads';

const run=async function run(i,corrected=true){
    if(typeof i.cancelChild!=='boolean'||!smallWhole(i.timeoutMs,20))return {held:true};
    const worker=new Worker('const {parentPort}=require("node:worker_threads");parentPort.postMessage("ready");setInterval(()=>{},1000);',{eval:true});
    try{await new Promise(resolve=>worker.once('message',resolve));await new Promise(resolve=>setTimeout(resolve,i.timeoutMs));
      if(corrected&&i.cancelChild)await worker.terminate();return {parent:'timed-out',childExited:worker.threadId===-1};
    }finally{if(worker.threadId!==-1)await worker.terminate();}
  };
const cases=[{"input":{"timeoutMs":5,"cancelChild":true},"corrected":false,"expected":{"parent":"timed-out","childExited":false}},{"input":{"timeoutMs":5,"cancelChild":true},"corrected":true,"expected":{"parent":"timed-out","childExited":true}},{"input":{"timeoutMs":5,"cancelChild":false},"corrected":true,"expected":{"parent":"timed-out","childExited":false}},{"input":{"timeoutMs":5,"cancelChild":null},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Download runnable example ↓

Choose from the boundary evidence

An explicitly parent-only rule permits a live child at observation. Missing child disposition is held before starting a worker.

  1. Start the controlled worker
  2. Apply the parent timeout disposition
  3. Inspect child exit before cleanup

Do not infer child cancellation from a parent-only timeout.

Editable boundary inputs and outputs
ConditionInput JSONExpected output JSON
parent-only timeout explicitly chosen{"timeoutMs":5,"cancelChild":false}{"parent":"timed-out","childExited":false}
child disposition unknown{"timeoutMs":5,"cancelChild":null}{"held":true}
Download editable CSV ↓

What extra evidence completes the base cancel-child requirement?

Show the worked answer

The actual worker has exited after awaited termination. The parent timed-out label alone supplies no such evidence.

Related resources