Skip to content

feat(server): listeningCallback#127

Merged
pi0 merged 3 commits intounjs:mainfrom
SukkaW:listen-callback
Apr 21, 2026
Merged

feat(server): listeningCallback#127
pi0 merged 3 commits intounjs:mainfrom
SukkaW:listen-callback

Conversation

@SukkaW
Copy link
Copy Markdown
Member

@SukkaW SukkaW commented Mar 27, 2026

This is part of #2.

Summary by CodeRabbit

  • New Features

    • The server listen method now accepts an optional callback parameter. When supplied, this callback is invoked once the server has successfully started listening and is operational.
  • Tests

    • Added/updated tests to verify the optional callback is invoked exactly once with no arguments when the server starts.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 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: 3f8c3cc3-6246-414b-8327-df9781e06fbb

📥 Commits

Reviewing files that changed from the base of the PR and between 39a9770 and 033342f.

📒 Files selected for processing (1)
  • src/server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/server.ts

📝 Walkthrough

Walkthrough

The ProxyServer.listen() method signature now accepts an optional listeningListener?: () => void callback and forwards it to the underlying _server.listen() call. Tests were updated to pass a mock callback and assert it is invoked once with no arguments.

Changes

Cohort / File(s) Summary
ProxyServer Listen Callback Support
src/server.ts
Extended listen(port, hostname?, listeningListener?) to accept an optional callback and pass it into _server.listen(...).
Listen Callback Test Coverage
test/server.test.ts
Updated #listen test to create a mock (vi.fn()), pass it to proxy.listen(0, "127.0.0.1", cb), and assert it was called once with no args.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A tiny listener hops in cheer,
I pass the callback, the server draws near.
One ring, one call — the startup is bright,
Tests clap their paws in the soft moonlight. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references the feature name 'listeningCallback' which directly matches the main change: adding an optional callback parameter to the listen method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (b227f65) to head (033342f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #127   +/-   ##
=======================================
  Coverage   94.91%   94.91%           
=======================================
  Files           8        8           
  Lines         786      786           
  Branches      320      320           
=======================================
  Hits          746      746           
  Misses         35       35           
  Partials        5        5           

☔ 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.

@SukkaW SukkaW requested review from Copilot and pi0 and removed request for pi0 March 27, 2026 04:00
@SukkaW SukkaW marked this pull request as ready for review March 27, 2026 04:00
Copy link
Copy Markdown

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

Adds support for providing a “listening” callback when starting a ProxyServer, aligning ProxyServer.listen(...) more closely with Node’s server.listen(...) callback behavior.

Changes:

  • Extend ProxyServer.listen to accept an optional listeningListener callback and forward it to the underlying server.
  • Update server.test.ts to assert that the listening callback is invoked.

Reviewed changes

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

File Description
src/server.ts Extends ProxyServer.listen signature and forwards the callback to the underlying server .listen() call.
test/server.test.ts Adds a new assertion that a provided listening callback is called when the proxy starts listening.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server.ts
Comment thread test/server.test.ts
Comment thread src/server.ts
Comment thread src/server.ts
@pi0 pi0 merged commit b75b9f9 into unjs:main Apr 21, 2026
5 checks passed
@SukkaW SukkaW mentioned this pull request Apr 21, 2026
58 tasks
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.

3 participants