Skip to content

test: stabilize cluster unix socket fixture#5907

Merged
killagu merged 1 commit into
nextfrom
agent/egg-dev/a04bf3d7
May 2, 2026
Merged

test: stabilize cluster unix socket fixture#5907
killagu merged 1 commit into
nextfrom
agent/egg-dev/a04bf3d7

Conversation

@killagu
Copy link
Copy Markdown
Contributor

@killagu killagu commented May 1, 2026

Summary

  • move the app-listen-path Unix socket test to a short tmpdir socket path provided through fixture env
  • clean the socket before startup and after teardown to avoid stale retry state

Verification

  • env HOME=/tmp EGG_HOME=/tmp corepack pnpm exec vitest run packages/cluster/test/app_worker.test.ts --testNamePattern "should use path in config" --retry 0 --testTimeout 30000 --hookTimeout 30000
  • env HOME=/tmp EGG_HOME=/tmp corepack pnpm exec vitest run packages/cluster/test/app_worker.test.ts --retry 0 --testTimeout 30000 --hookTimeout 30000 (twice)
  • corepack pnpm exec oxlint packages/cluster/test/app_worker.test.ts packages/cluster/test/fixtures/apps/app-listen-path/config/config.default.js
  • corepack pnpm --filter @eggjs/cluster run typecheck

Notes

  • Root CI command env HOME=/tmp EGG_HOME=/tmp CI=true corepack pnpm exec ut run ci exits before tests because ut run clean-dist calls a missing clean script.
  • Package coverage command env HOME=/tmp EGG_HOME=/tmp CI=true corepack pnpm --filter @eggjs/cluster run test -- --coverage reaches unrelated local runner failures from direct loading of tegg decorator syntax in tegg/core/background-task/src/BackgroundTaskHelper.ts.

Summary by CodeRabbit

  • New Features

    • Socket listening path can be overridden via the EGG_APP_LISTEN_PATH_SOCKET environment variable, with fallback to the default path.
  • Tests

    • Tests now use per-process temporary socket paths and ensure proper setup/teardown cleanup so parallel runs are isolated and deterministic.

Copilot AI review requested due to automatic review settings May 1, 2026 16:05
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b59cd74-bc74-4762-80a7-937d3637fae7

📥 Commits

Reviewing files that changed from the base of the PR and between c681bc0 and 25fd34c.

📒 Files selected for processing (2)
  • packages/cluster/test/app_worker.test.ts
  • packages/cluster/test/fixtures/apps/app-listen-path/config/config.default.js
✅ Files skipped from review due to trivial changes (1)
  • packages/cluster/test/fixtures/apps/app-listen-path/config/config.default.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cluster/test/app_worker.test.ts

📝 Walkthrough

Walkthrough

Tests now generate ephemeral Unix socket paths using the OS temp directory, process.pid, and randomness; they remove any pre-existing socket before each run and inject the path into the child process via EGG_APP_LISTEN_PATH_SOCKET. App config reads this env var with a fallback to the original socket path.

Changes

Cohort / File(s) Summary
Test + Fixture
packages/cluster/test/app_worker.test.ts, packages/cluster/test/fixtures/apps/app-listen-path/config/config.default.js
Tests generate per-process temporary socket paths, remove stale socket files in beforeEach, pass the socket path into child processes via EGG_APP_LISTEN_PATH_SOCKET, and the fixture config reads that env var with a fallback to the default socket path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • jerryliang64

Poem

🐇 I drew a path in temp by moonlight's grin,

process.pid and randomness tucked within.
Socket cleaned before each tiny quest,
Env tells the app where to rest.
Hoppity tests — all tidy, all blessed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: stabilize cluster unix socket fixture' directly and clearly describes the main objective of the changeset: improving test stability for the cluster Unix socket fixture by using ephemeral socket paths and proper cleanup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/egg-dev/a04bf3d7

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.03%. Comparing base (101ab97) to head (25fd34c).
⚠️ Report is 16 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5907      +/-   ##
==========================================
- Coverage   85.04%   85.03%   -0.02%     
==========================================
  Files         665      665              
  Lines       19100    19100              
  Branches     3716     3716              
==========================================
- Hits        16244    16242       -2     
- Misses       2463     2465       +2     
  Partials      393      393              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the test suite to use dynamic Unix domain socket paths in the system's temporary directory, replacing hardcoded paths within the application directory. Key changes include generating a socket path using the process ID in app_worker.test.ts, ensuring the socket file is removed before each test, and passing the path to the application via the EGG_APP_LISTEN_PATH_SOCKET environment variable. Feedback suggests appending a random string to the socket filename to further mitigate collision risks in multi-threaded test environments.

Comment thread packages/cluster/test/app_worker.test.ts Outdated
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 1, 2026

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25fd34c
Status: ✅  Deploy successful!
Preview URL: https://05013586.egg-cci.pages.dev
Branch Preview URL: https://agent-egg-dev-a04bf3d7.egg-cci.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 1, 2026

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25fd34c
Status: ✅  Deploy successful!
Preview URL: https://edff6714.egg-v3.pages.dev
Branch Preview URL: https://agent-egg-dev-a04bf3d7.egg-v3.pages.dev

View logs

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

Stabilizes the app-listen-path Unix socket fixture used by @eggjs/cluster tests by allowing the socket path to be injected via env and by cleaning up stale socket files between runs.

Changes:

  • Allow the fixture’s cluster.listen.path to be overridden via EGG_APP_LISTEN_PATH_SOCKET.
  • Update the listen config test to use a temp socket path and remove stale socket files before/after each test run.

Reviewed changes

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

File Description
packages/cluster/test/fixtures/apps/app-listen-path/config/config.default.js Adds env override for the Unix socket listen path to support shorter / temp socket locations.
packages/cluster/test/app_worker.test.ts Switches the socket test to use a tmp socket path via env and adds cleanup logic for stale sockets.
Comments suppressed due to low confidence (2)

packages/cluster/test/app_worker.test.ts:217

  • afterEach closes app unconditionally and also calls mm.restore(), but app is a shared let that can be undefined if the test fails before assignment. This can throw in cleanup and mask the original failure. Also, this duplicates the file-level afterEach(() => app && app.close()) / afterEach(mm.restore) hooks, leading to double-close/double-restore.

Consider guarding (if (app) await app.close()), and avoid calling mm.restore() here (or otherwise ensure close/restore only happens once, ideally with a single awaited close).

    afterEach(async () => {
      await app.close();
      await mm.restore();
    });

packages/cluster/test/app_worker.test.ts:218

  • rm(sockFile, { recursive: true }) is unnecessary for a socket file and widens the blast radius if sockFile ever points at a directory (e.g., via an unexpected value). Using rm(sockFile, { force: true }) (no recursive) is safer and still removes stale socket files.
      mm.env('default');
      await rm(sockFile, { force: true, recursive: true });
    });
    afterEach(async () => {
      await app.close();
      await mm.restore();
    });
    afterEach(() => rm(sockFile, { force: true, recursive: true }));

@killagu killagu force-pushed the agent/egg-dev/a04bf3d7 branch from c681bc0 to 25fd34c Compare May 1, 2026 16:33
@killagu killagu merged commit 88fa8e4 into next May 2, 2026
24 of 26 checks passed
@killagu killagu deleted the agent/egg-dev/a04bf3d7 branch May 2, 2026 15:01
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.

2 participants