Skip to content

collector_test.sh overrides local collector port as configured in env even if available #152

@anomit

Description

@anomit

Describe the bug

The collector_test.sh script unconditionally overrides the LOCAL_COLLECTOR_PORT environment variable even when the configured port is available and not in use. This causes issues when users explicitly configure a specific port via environment files, as the script ignores the configured value and replaces it with any available port it finds.

To Reproduce

Affected versions: All versions with collector_test.sh

Steps to reproduce the behavior:

  1. Configure LOCAL_COLLECTOR_PORT=50068 in your environment file (e.g., .env-mainnet-UNISWAPV2-ETH)
  2. Run ./build.sh which calls collector_test.sh
  3. Observe that even though port 50068 is available, the script finds port 50051 and overwrites the env file
  4. The configured port preference is lost and replaced with the first available port in the range

Expected behavior
The script should respect explicitly configured LOCAL_COLLECTOR_PORT values and only search for alternative ports when the configured port is actually in use by another service.

Proposed Solution
Modify collector_test.sh to:

  1. Only search for alternative ports when the configured port is actually in use (has active connections)
  2. Reuse the existing port connectivity test results instead of duplicating the check
  3. Preserve explicitly configured ports when they are available

Caveats

  • The fix maintains backward compatibility for cases where no port is configured
  • Port conflict detection relies on the same connectivity testing methods already in use
  • The script will still override ports when there are genuine conflicts

Additional context

  • Issue occurs on macOS and likely other Unix-like systems
  • Affects Docker-based deployments where port configuration is critical
  • Related to collector service initialization in snapshotter-lite-v2

Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions