Skip to content

fix(tests): resolve failing tests in TemplateArchiveProcessor and JavaScriptEvaluator (#65)#79

Merged
mttrbrts merged 3 commits intoaccordproject:mainfrom
mdawoud27:mdawoud27/65/fix-test-failures
Apr 26, 2026
Merged

fix(tests): resolve failing tests in TemplateArchiveProcessor and JavaScriptEvaluator (#65)#79
mttrbrts merged 3 commits intoaccordproject:mainfrom
mdawoud27:mdawoud27/65/fix-test-failures

Conversation

@mdawoud27
Copy link
Copy Markdown
Contributor

@mdawoud27 mdawoud27 commented Jan 31, 2026

Fixes #65

Resolves two test failures:

  1. Fix Race Condition (worker.js): Added a callback and delay to process.send() to ensure IPC messages are flushed before the worker exits. Fixes flaky JavaScriptEvaluator stress tests.
  2. Fix Validation Error (TemplateMarkInterpreter.ts): Updated getJsonPath to ignore the top-level node name 'top', fixing incorrect JSON paths that caused ValidationException in TemplateArchiveProcessor.

Verified that all tests pass

Screenshot From 2026-01-31 11-33-35

Signed-off-by: Mohamed Dawoud mhmaddawoud20@gmail.com

Signed-off-by: Mohamed Dawoud <mhmaddawoud20@gmail.com>
Signed-off-by: Mohamed Dawoud <mhmaddawoud20@gmail.com>
Copy link
Copy Markdown
Member

@mttrbrts mttrbrts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Clean fix for the test failures from #65. Thank you @mdawoud27!


This comment was generated by AI on behalf of @mttrbrts.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes two failing tests by addressing a child-process IPC race in JS evaluation and correcting JSON-path generation for TemplateMark root nodes.

Changes:

  • Update src/worker.js to delay process exit until after the IPC send callback fires (to reduce flakiness in JavaScriptEvaluator stress tests).
  • Update getJsonPath in src/TemplateMarkInterpreter.ts to ignore the top-level node name "top" (fixing incorrect JSON paths leading to validation failures).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/worker.js Adds process.send callbacks + delayed exits to avoid losing IPC messages before worker termination.
src/TemplateMarkInterpreter.ts Adjusts JSON path construction to skip the "top" node name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/worker.js
Comment on lines +37 to +41
process.send({ result }, () => {
setTimeout(() => {
process.exit();
}, 50);
});
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra 50ms delay after process.send adds a fixed latency to every child-process evaluation and can significantly slow down/stress timeouts under load. The process.send callback already indicates the message has been flushed to the IPC channel, so consider exiting immediately in the callback (or prefer process.exitCode = 0/1 + process.disconnect() to let the process exit naturally) instead of setTimeout(..., 50).

Copilot uses AI. Check for mistakes.
Comment thread src/worker.js
Comment on lines +44 to +48
process.send({ message: err.toString() }, () => {
setTimeout(() => {
process.exit(1);
}, 50);
});
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the success path: delaying exit by 50ms after sending the error message adds avoidable per-request latency and can impact throughput. Consider exiting immediately in the process.send callback (or set process.exitCode = 1 and process.disconnect()), rather than sleeping for 50ms.

Copilot uses AI. Check for mistakes.
Comment thread src/TemplateMarkInterpreter.ts Outdated
}

if (currentNode.name !== 'this') {
if (currentNode.name !== "this" && currentNode.name !== "top") {
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line introduces double-quoted string literals in a file that otherwise consistently uses single quotes (e.g., obj.name !== 'top' above). For consistency and to reduce noisy diffs, use single quotes here as well.

Suggested change
if (currentNode.name !== "this" && currentNode.name !== "top") {
if (currentNode.name !== 'this' && currentNode.name !== 'top') {

Copilot uses AI. Check for mistakes.
@mttrbrts
Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

Address Copilot review comments:
- Remove setTimeout delays in process.exit() callbacks
- Use single quotes for consistency in TemplateMarkInterpreter.ts

The process.send callback already indicates message delivery,
so exiting immediately is safe and improves throughput.

Signed-off-by: Matt Roberts <code@rbrts.uk>
@mttrbrts mttrbrts requested a review from a team April 26, 2026 20:24
@mttrbrts
Copy link
Copy Markdown
Member

I've pushed a commit to address the Copilot review comments:

Changes made:

  1. Removed 50ms setTimeout delays in worker.js - The process.send callback already indicates the IPC message has been flushed, so exiting immediately is safe and improves throughput
  2. Fixed quote consistency in TemplateMarkInterpreter.ts - Changed "this" and "top" to 'this' and 'top' to match the single-quote style used throughout the codebase

All 50 tests still pass.

@mttrbrts mttrbrts enabled auto-merge (squash) April 26, 2026 20:25
@mttrbrts mttrbrts merged commit 6f3575e into accordproject:main Apr 26, 2026
10 checks passed
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24966232529

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Warning

No base build found for commit 6723fd6 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 63.844%

Details

  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 1128
Covered Lines: 719
Line Coverage: 63.74%
Relevant Branches: 537
Covered Branches: 344
Branch Coverage: 64.06%
Branches in Coverage %: Yes
Coverage Strength: 5414.98 hits per line

💛 - Coveralls

@mdawoud27 mdawoud27 deleted the mdawoud27/65/fix-test-failures branch April 27, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix failing test on the main branch

4 participants