Worker Execution Logic

This part is the specific logic that runs within a worker. It receives the configuration and triggers the execution of a batch of test files.

Columns are parts of the code, grouped by process. Read top to bottom. Solid arrow: hands work over. Dashed: the reply. Purple: crosses between processes. Hook: work inside one part. Dashed boxes repeat. Hover a column name or a step for its full text.

WORKER-FILE PROCESSDispose each listenerExecute tests in parallelLoad worker implementationPass to options builderDispose listenersRequest fork IPC optionsReturn fork IPC optionsBuild fork transport optionsConstruct fork RPC optionsRequest thread optionsReturn thread optionsBuild thread transport optionsConstruct thread RPC optionsRequest VM fork optionsReturn VM fork optionsBuild VM fork transportConstruct VM fork RPCRequest VM thread optionsReturn VM thread op…Build VM thread transportConstruct VM thread RPCDispatch tests in run modeExecute tests in forkRestore serialized configParse wrapped regex stringsPrepare caches and executeRun…
Worker Entry
RPC Options
Fork Worker
Thread Worker
VM Fork
VM Thread
Base Worker
1Load worker and initialize state — The worker entry point loads the implementation and disposes of any existing internal listeners, ignoring any errors that occur during cleanup. It sets up environment identifiers and inspector settings, rejecting relative paths and ensuring defaults are properly configured. Fresh caches and state are created for the upcoming run.
2Build transport options — The RPC options builder constructs the necessary transport options for communication, such as IPC for forks or message ports for threads. It restores configuration values that were altered during the serialization process, parsing wrapped regular expression strings. This ensures the worker has the correct configuration settings to proceed.
3Dispatch tests in run mode — The fork worker logic dispatches a batch of tests in run mode, preparing to execute them within a forked process using V8 serialization. It saves the current process exit behavior to restore it later after execution. This step coordinates the transition from configuration preparation to actual test execution.
4Prepare caches and execute batch — The base worker core prepares shared caches for modules and execution information, reusing existing caches where possible. It deletes any invalidated paths and mock variants, then lazily creates and caches the test executor if it does not already exist. The test batch is then executed with the prepared environment and options.
5Return test results — The fork worker logic receives the results from the executed test batch and ensures the process exit behavior is restored to its original state. Any errors encountered during execution are handled appropriately before the results are finalized. The completed results are then sent back to the entry point.
STEP · hover for full text