This ticket addresses a framework bug discovered during the migration of unit tests to Playwright. Intermittent test failures pointed to a race condition caused by prototype pollution within the Neo.setupClass method in src/Neo.mjs.
The Bug
The setupClass method was directly mutating the static config object of the class it was processing. While setupClass is gated to only run once per class, this direct mutation of a static property is unsafe in a parallel environment and caused race conditions between tests running in different workers.
The Fix
The fix ensures that setupClass operates on a deep clone of the static config object and related configDescriptors, preventing any modification of the original class definition. This was achieved by:
- Changing
cfg = ctor.config || {}; to cfg = ctor.config ? Neo.clone(ctor.config, true) : {}; to work on a clone.
- Introducing a local
currentConfigDescriptors variable to prevent direct mutation of the static ctor.configDescriptors property during the build-up phase.
This change resolves the intermittent test failures and makes the class setup process more robust and safe for concurrent environments.
This ticket addresses a framework bug discovered during the migration of unit tests to Playwright. Intermittent test failures pointed to a race condition caused by prototype pollution within the
Neo.setupClassmethod insrc/Neo.mjs.The Bug
The
setupClassmethod was directly mutating the staticconfigobject of the class it was processing. WhilesetupClassis gated to only run once per class, this direct mutation of a static property is unsafe in a parallel environment and caused race conditions between tests running in different workers.The Fix
The fix ensures that
setupClassoperates on a deep clone of the staticconfigobject and relatedconfigDescriptors, preventing any modification of the original class definition. This was achieved by:cfg = ctor.config || {};tocfg = ctor.config ? Neo.clone(ctor.config, true) : {};to work on a clone.currentConfigDescriptorsvariable to prevent direct mutation of the staticctor.configDescriptorsproperty during the build-up phase.This change resolves the intermittent test failures and makes the class setup process more robust and safe for concurrent environments.