Skip to content

Conversation

FrozenPandaz
Copy link
Collaborator

Current Behavior

The E2E global setup hardcodes local registry configuration and waits for a specific localhost registry to be available, which can cause issues when the registry setup is managed differently or when using external registries.

Expected Behavior

The E2E setup should be more flexible and work with different registry configurations:

  • Wait for the registry configuration to change from the default instead of assuming local registry
  • Properly manage local registry processes with cleanup
  • Work with both local and external registries
  • Provide better error handling and logging

Related Issue(s)

This PR improves the E2E local testing setup to be more robust and flexible.

Changes Made

  • Changed from hardcoded local registry waiting to detecting registry configuration changes
  • Added proper process management for local registry startup
  • Improved error handling and cleanup with process termination
  • Made registry configuration work with both local and external registries
  • Refactored code into smaller, focused functions for better maintainability
  • Added better logging for debugging setup issues

@FrozenPandaz FrozenPandaz requested review from meeroslav, vsavkin, mandarini and a team as code owners June 5, 2025 22:58
@FrozenPandaz FrozenPandaz requested a review from leosvelperez June 5, 2025 22:58
Copy link

vercel bot commented Jun 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jun 10, 2025 7:55pm

Copy link
Contributor

nx-cloud bot commented Jun 5, 2025

View your CI Pipeline Execution ↗ for commit c21faf7.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 1h 40m 17s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 18s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 4s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 4s View ↗
nx documentation ✅ Succeeded 1m 34s View ↗

☁️ Nx Cloud last updated this comment at 2025-06-10 21:31:34 UTC

// Keep checking until the configured registry changes from default
while (currentRegistry === defaultRegistry) {
console.log(
'Waiting for registry configuration to change from default...'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe include what the default is in the log to avoid any confusion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@claude can you include the default in the log please?

Copy link
Contributor

@claude claude bot Jun 6, 2025

Choose a reason for hiding this comment

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

Claude encountered an error —— View job


Todo List

  • Read the current file to understand the log message that needs updating
  • Identify what the default registry value is
  • Update the log message to include the default value
  • Commit the change to the PR branch

Summary

I've successfully updated the log message on line 41 of e2e/utils/global-setup.ts to include the default registry value for better clarity.

Change Made:

- 'Waiting for registry configuration to change from default...'
+ `Waiting for registry configuration to change from default (${defaultRegistry})...`

This will now log: Waiting for registry configuration to change from default (https://registry.npmjs.org/)... making it clear what the "default" registry is.

The change has been committed to the PR branch: 72fa6f0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@claude Instead of printing default (https://registry.npmjs.org/), just print the default URL.

Copy link
Contributor

@claude claude bot Jun 6, 2025

Choose a reason for hiding this comment

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

Claude finished @FrozenPandaz's task in 54s —— View job


Todo List

  • Read the current file to understand the log message that needs updating
  • Update the log message to print just the default URL (remove "default" text and parentheses)
  • Commit the change to the PR branch

Summary

I've successfully updated the log message in e2e/utils/global-setup.ts on line 41 to simplify the output as requested.

Change Made:

- `Waiting for registry configuration to change from default (${defaultRegistry})...`
+ `Waiting for registry configuration to change from ${defaultRegistry}...`

Now the log will print just the URL (e.g., Waiting for registry configuration to change from https://registry.npmjs.org/...) without the extra "default" text and parentheses.

The change has been committed to the PR branch: c184bea


Comment on lines +99 to +115
function parseRegistryUrl(registryUrl: string): {
hostname: string;
port: string;
} {
try {
const url = new URL(registryUrl);
return {
hostname: url.hostname,
port: url.port || (url.protocol === 'https:' ? '443' : '80'),
};
} catch {
// Fallback for invalid URLs
return {
hostname: 'localhost',
port: '4873',
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The parseRegistryUrl function may not handle protocol-less URLs correctly. The URL constructor requires a protocol to properly parse URLs. Consider adding validation to handle cases like localhost:4873 by prepending http:// when no protocol is detected:

function parseRegistryUrl(registryUrl: string): {
  hostname: string;
  port: string;
} {
  try {
    // Add protocol if missing
    const urlWithProtocol = registryUrl.includes('://')
      ? registryUrl
      : `http://${registryUrl}`;
    const url = new URL(urlWithProtocol);
    // Rest of the function...
  }
  // ...
}

This would make the function more robust when handling various registry URL formats.

Suggested change
function parseRegistryUrl(registryUrl: string): {
hostname: string;
port: string;
} {
try {
const url = new URL(registryUrl);
return {
hostname: url.hostname,
port: url.port || (url.protocol === 'https:' ? '443' : '80'),
};
} catch {
// Fallback for invalid URLs
return {
hostname: 'localhost',
port: '4873',
};
}
function parseRegistryUrl(registryUrl: string): {
hostname: string;
port: string;
} {
try {
// Add protocol if missing
const urlWithProtocol = registryUrl.includes('://')
? registryUrl
: `http://${registryUrl}`;
const url = new URL(urlWithProtocol);
return {
hostname: url.hostname,
port: url.port || (url.protocol === 'https:' ? '443' : '80'),
};
} catch {
// Fallback for invalid URLs
return {
hostname: 'localhost',
port: '4873',
};
}
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's okay, the registry URL will for sure have the protocol.

FrozenPandaz and others added 4 commits June 10, 2025 15:42
Wait for registry configuration to change from default instead of hardcoded local registry.
Add proper process management for local registry startup with cleanup.
Improve error handling and make registry configuration work with both local and external registries.
@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Medium Priority (not high, not low priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants