Skip to content

Conversation

@Karthikeya1500
Copy link

This PR updates the Node.js HTTP polyfill so that Server.setTimeout() behaves as a no-op, matching Node.js behavior.
Currently, Deno prints:

Not implemented: Server.setTimeout()

when frameworks like Fastify call this method internally.
This warning is unnecessary and creates console noise even though the call is harmless.

Related Issue

Fixes #31221

Details

In Node.js, calling server.setTimeout() without arguments is a no-op.
The previous Deno polyfill printed a warning instead of following this behavior.

This PR changes the method in:

deno/ext/node/polyfills/http.ts

from:

setTimeout() {
  console.error("Not implemented: Server.setTimeout()");
}

to:

ts
setTimeout(_msecs?: number, _callback?: () => void) {
  // No-op for Node.js compatibility
  return this;
}

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

Replaces the previous "Not implemented" error in ServerImpl.setTimeout() with a no-op compatibility shim that accepts optional msecs and callback parameters and returns this, preserving chaining and suppressing the error path.

Changes

Cohort / File(s) Change Summary
HTTP Server setTimeout Polyfill
ext/node/polyfills/http.ts
Replaced throwing "Not implemented" in ServerImpl.setTimeout() with a no-op implementation: setTimeout(_msecs?: number, _callback?: () => void): this that performs no action and returns this for chaining compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Fastify / user code
    participant Server as ServerImpl.setTimeout()

    Note over Server: Previously threw "Not implemented" error
    Caller->>Server: setTimeout(msecs?, callback?)
    Server-->>Caller: returns ServerImpl (this)  %% no-op shim replaces error %%
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check method signature matches Node compatibility expectations.
  • Confirm returned this enables chaining in common call sites (e.g., Fastify).
  • Ensure no unintended side effects or TypeScript type regressions in ext/node/polyfills/http.ts.

Poem

🐰 A little shim, light on its feet,
setTimeout hops back, no error to meet.
Chains stay intact, logs calm and bright,
Fast servers hum through day and night.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(node): make Server.setTimeout a no-op to match Node.js' clearly and concisely describes the main change: converting a not-implemented method to a no-op.
Description check ✅ Passed The description clearly explains the problem, solution, and code changes related to making Server.setTimeout a no-op in the Node.js HTTP polyfill.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #31221: converting Server.setTimeout from logging 'Not implemented' to a proper no-op that returns 'this' for method chaining, eliminating console noise while maintaining Node.js compatibility.
Out of Scope Changes check ✅ Passed The change is narrowly focused and directly addresses the linked issue; only the Server.setTimeout method signature and implementation are modified to fix the specific problem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
ext/node/polyfills/http.ts (2)

2160-2163: LGTM! Implementation correctly achieves the PR objective.

The no-op implementation eliminates the console warning while maintaining method chaining by returning this. The parameter names with underscore prefixes appropriately signal they're intentionally unused.

Consider adding an explicit return type annotation for clarity:

-  setTimeout(_msecs?: number, _callback?: () => void) {
+  setTimeout(_msecs?: number, _callback?: () => void): this {
     // No-op for Node.js compatibility
     return this;
   }

2165-2165: Minor: Extra blank line.

The additional blank line at this location appears unnecessary, though this is a minor stylistic detail.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61416 and b01435f.

📒 Files selected for processing (1)
  • ext/node/polyfills/http.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: bench release linux-x86_64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test release macos-x86_64
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: build libs

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ext/node/polyfills/http.ts (1)

2160-2163: LGTM! Successfully eliminates console warnings while maintaining API compatibility.

The no-op implementation correctly:

  • Returns this for method chaining (matches Node.js)
  • Accepts the expected parameters
  • Suppresses the previous "Not implemented" error

Optional enhancement: In Node.js, when callback is provided, it's registered as a 'timeout' event listener via this.on('timeout', callback). While not required for the current use case (suppressing Fastify warnings), registering the callback would improve compatibility:

 setTimeout(_msecs?: number, _callback?: () => void) {
   // No-op for Node.js compatibility
+  if (_callback) {
+    this.on('timeout', _callback);
+  }
   return this;
 }

However, since the PR explicitly aims for a no-op and frameworks like Fastify work without this, the current implementation is sufficient.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b01435f and 2366ab6.

📒 Files selected for processing (1)
  • ext/node/polyfills/http.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: lint debug linux-x86_64
  • GitHub Check: build libs

@Tango992
Copy link
Member

I don't think silencing the error does any justice here. In node's implementation, the Server.setTimeout option is respected and not a no-op.

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.

Fastify works but prints message "Not implemented: Server.setTimeout()"

3 participants