Skip to content

Conversation

@sfreudenthaler
Copy link
Member

@sfreudenthaler sfreudenthaler commented Jan 2, 2026

Summary

Fixes the recurring ~20 minute timeout issue in GitHub Actions Frontend Unit Tests.

Root Causes Identified

  1. TypeScript API errors preventing test compilation

    • Using deprecated/non-existent router.currentNavigation() instead of getCurrentNavigation()
  2. Jest worker processes not exiting gracefully

    • Tests leaking resources (timers, handles, promises)
    • Workers hanging after cumulative test execution

Changes

TypeScript API Fixes

  • router.currentNavigation()router.getCurrentNavigation()
  • Files: dot-router.service.ts, edit-page.guard.ts

Test Mock Updates

  • ✅ Updated all test mocks to match corrected API
  • Files: dot-router.service.spec.ts, dot-navigation.service.spec.ts, edit-page.guard.spec.ts

Jest Configuration (pom.xml)

  • ✅ Added --detectOpenHandles to identify resource leaks
  • ✅ Added --forceExit to force cleanup even with leaks
  • ✅ Fixed command line syntax for proper argument passing

Test Results

Before

  • ❌ Tests timed out at ~20 minutes consistently
  • ❌ TypeScript compilation errors
  • ❌ "The operation was canceled" errors

After

  • ✅ Tests run for 31+ minutes successfully
  • ✅ All compilation errors resolved
  • ✅ Tests complete without cancellation
  • ✅ Detected 1 minor PIPEWRAP leak in ng-mocks library (non-critical)

Impact

  • Resolves CI blocking issue
  • Allows PRs to merge to trunk
  • Provides better visibility into resource leaks for future debugging

Closes #34194

This PR fixes: #34194

…ction

Minimal changes to identify root cause of 20min timeout:

1. Fix TypeScript compilation errors:
   - router.currentNavigation() -> getCurrentNavigation()
   - Prevents test compilation failures

2. Add leak detection:
   - Only --detectOpenHandles flag (no forceExit, no config changes)
   - Will show which tests are leaking resources

This minimal approach lets us see the actual leak source without
changing test execution environment or Jest configuration.

Related: #34166
The issue was command line parsing, not the TypeScript fixes.

Problem: Single quotes and -- separator were breaking argument parsing:
  yarn nx affected -t test --base=origin/main --exclude='tag:skip:test' -- --detectOpenHandles

This was being parsed by Yarn as:
  nx affected --detectOpenHandles  (missing all the other args!)

Solution: Remove quotes and -- separator:
  yarn nx affected -t test --base=origin/main --exclude=tag:skip:test --detectOpenHandles

Note: TypeScript API fixes (currentNavigation -> getCurrentNavigation)
are REQUIRED and should NOT be backed out - those are real compilation errors.

Related: #34166
Problem: --detectOpenHandles makes Jest wait forever for handles to close
Solution: Add --forceExit so Jest reports what it detected and exits

Together these flags:
- --detectOpenHandles = detect leaking resources
- --forceExit = force exit and SHOW the detections

Without --forceExit, Jest hangs indefinitely waiting for handles to close.

Related: #34166
Update all test mocks to use getCurrentNavigation() instead of currentNavigation():
- core-web/libs/data-access/src/lib/dot-router/dot-router.service.spec.ts
- core-web/apps/dotcms-ui/src/app/view/components/dot-navigation/services/dot-navigation.service.spec.ts
- core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.spec.ts

This fixes the test failures caused by updating the Angular Router API.

Related: #34166
@sfreudenthaler
Copy link
Member Author

@dotCMS/frontend i'm not so sure about these and would love your feedback

Using deprecated/non-existent router.currentNavigation() instead of getCurrentNavigation()

@nicobytes nicobytes self-requested a review January 2, 2026 15:09
Copy link
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

This PR resolves CI timeout issues in Frontend Unit Tests by fixing deprecated TypeScript Router API usage and enhancing Jest configuration to detect and handle resource leaks. The changes address TypeScript compilation errors and Jest worker processes hanging after test execution.

Key Changes

  • Fixed deprecated router.currentNavigation() calls to use the correct router.getCurrentNavigation() API across production and test code
  • Updated Jest configuration to add --detectOpenHandles and --forceExit flags for better resource leak detection and forced cleanup
  • Updated all associated test mocks to match the corrected API signatures

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core-web/pom.xml Added Jest flags (--detectOpenHandles, --forceExit) to identify resource leaks and force test completion
core-web/libs/data-access/src/lib/dot-router/dot-router.service.ts Replaced deprecated currentNavigation() with getCurrentNavigation() in queryParams getter
core-web/libs/data-access/src/lib/dot-router/dot-router.service.spec.ts Updated RouterMock to implement getCurrentNavigation() and updated test spy calls
core-web/apps/dotcms-ui/src/app/view/components/dot-navigation/services/dot-navigation.service.spec.ts Renamed mock method from currentNavigation() to getCurrentNavigation()
core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.ts Fixed guard to use getCurrentNavigation() for accessing navigation state
core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.spec.ts Updated test mock to use getCurrentNavigation()

consistency

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sfreudenthaler sfreudenthaler added this pull request to the merge queue Jan 2, 2026
Merged via the queue into main with commit d58b3af Jan 2, 2026
39 checks passed
@sfreudenthaler sfreudenthaler deleted the 34194-frontend-test-cancellations-caused-by-nx-parallel-3-change-exposing-uncleaned-test-resources branch January 2, 2026 17:53
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.

Frontend test cancellations caused by nx parallel: 3 change exposing uncleaned test resources

5 participants