Skip to content

Conversation

@sfreudenthaler
Copy link
Member

Purpose

Minimal, surgical fix to identify the root cause of Frontend Unit Tests timeout (~20 minutes).

Strategy

Changed ONLY what's absolutely necessary:

  1. ✅ Fix TypeScript compilation errors (tests won't run without this)
  2. ✅ Add --detectOpenHandles flag to see what's leaking

Intentionally NOT changing:

  • ❌ Jest configuration (testTimeout, maxWorkers)
  • ❌ GitHub Actions logging
  • --forceExit flag (want to see real failure)

Changes

TypeScript API Fixes (Required)

// core-web/libs/data-access/src/lib/dot-router/dot-router.service.ts
- const nav = this.router.currentNavigation();
+ const nav = this.router.getCurrentNavigation();

// core-web/apps/dotcms-ui/src/app/api/services/guards/ema-app/edit-page.guard.ts
- const url = router.currentNavigation().extractedUrl.queryParams['url'];
+ const url = router.getCurrentNavigation().extractedUrl.queryParams['url'];

Leak Detection (Debug Only)

<!-- core-web/pom.xml -->
<arguments>nx affected -t test --base=origin/main --exclude='tag:skip:test' -- --detectOpenHandles</arguments>

Expected Output

Based on previous debug run showing:

A worker process has failed to exit gracefully and has been force exited.
This is likely caused by tests leaking due to improper teardown.
Try running with --detectOpenHandles to find leaks.

We should now see:

Jest has detected the following X open handle(s) potentially keeping Jest from exiting:

  ● TIMEOUT/TCPWRAP/etc

      at libs/some-library/some-file.spec.ts:123:45

This will tell us EXACTLY which test file and line is leaking resources.

Testing Plan

  1. Monitor "Frontend Unit Tests" job
  2. Look for "Jest has detected" messages in logs
  3. Identify specific test files causing leaks
  4. Fix those specific tests in a follow-up PR

Previous Attempt

Closed #34191 - made too many changes at once, harder to debug.

Related: #34166

fmontes and others added 19 commits December 24, 2025 11:53
- Replaced the usage header with a PrimeNG toolbar for better action handling.
- Enhanced loading state with a more structured skeleton layout for site metrics, system configuration, and user activity.
- Updated error handling to use PrimeNG card components for a cleaner presentation.
- Refactored dashboard content layout to utilize flexbox for better responsiveness.
- Adjusted SCSS styles to align with new component structure and improve overall styling consistency.

This update enhances the user experience and maintains a modern design approach.
…yling

- Adjusted skeleton component heights for better visual consistency.
- Added margin utility class to paragraph elements within skeleton templates.
- Enhanced SCSS styles for skeleton display and h3 elements to improve layout and readability.

These changes aim to refine the user interface and enhance the loading experience in the dot-usage-shell component.
- Introduced DotUsageService to fetch usage summary metrics from the backend API.
- Implemented error handling for various HTTP status codes.
- Added unit tests for DotUsageService to validate summary retrieval and error handling.
- Updated dot-usage-shell component to manage loading and error states using signals.
- Refactored component tests to utilize the new service structure.

These changes enhance the functionality and reliability of the dot-usage feature, ensuring accurate data retrieval and user-friendly error messages.
…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
@sfreudenthaler
Copy link
Member Author

Fixed Command Line Parsing Issue

The error was NOT related to the TypeScript API fixes - those are required.

The Problem

The Maven command had syntax issues:

<!-- BROKEN -->
<arguments>nx affected -t test --base=origin/main --exclude='tag:skip:test' -- --detectOpenHandles</arguments>

Yarn was parsing this as:

nx affected --detectOpenHandles  # Missing all the other arguments!

The Fix

<!-- FIXED -->
<arguments>nx affected -t test --base=origin/main --exclude=tag:skip:test --detectOpenHandles</arguments>

Removed:

  • Single quotes around 'tag:skip:test'
  • The -- separator before --detectOpenHandles

Why Keep the TypeScript Fixes?

The currentNavigation() → getCurrentNavigation() changes are real compilation errors that prevent tests from running at all. Without them, you get:

error TS2551: Property 'currentNavigation' does not exist on type 'Router'.
Did you mean 'getCurrentNavigation'?

Tests should now run properly with --detectOpenHandles showing us which tests leak resources.

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
@sfreudenthaler
Copy link
Member Author

Update: Added --forceExit Flag

What Happened

The previous run with only --detectOpenHandles hung indefinitely at 22:08:26 GMT.

Why It Hung

--detectOpenHandles makes Jest wait forever for open handles to close before reporting. Since the handles never close (that's the bug!), Jest never completes.

The Fix

Added --forceExit flag:

<arguments>nx affected -t test --base=origin/main --exclude=tag:skip:test --detectOpenHandles --forceExit</arguments>

How these work together:

  • --detectOpenHandles = Detect what resources are leaking
  • --forceExit = Force Jest to exit and show the detections

What to Expect Next

Tests will now:

  1. ✅ Run to completion (instead of hanging)
  2. 📊 Show us which specific test files have open handles
  3. 📝 Print messages like:
    Jest has detected the following X open handle(s):
    
      ● TIMEOUT
    
          at libs/edit-content/src/lib/some.spec.ts:147:9
    

This will tell us exactly which tests need to be fixed.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants