Compare commits

...

3 Commits

Author SHA1 Message Date
Claude Bot
a9b7188379 refactor(test): use tls from harness instead of inlining certs
Replace duplicated inline TLS certificates with the shared `tls`
export from harness to improve test maintainability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 00:44:07 +00:00
autofix-ci[bot]
4083d6fa27 [autofix.ci] apply automated fixes 2025-11-27 09:05:54 +00:00
Claude Bot
0c5443ae0f fix(http2): return server from setTimeout for method chaining (#24924)
Make Http2Server.setTimeout() and Http2SecureServer.setTimeout() return
`this` to enable method chaining, matching Node.js behavior.

Before: server.setTimeout(1000).listen() // TypeError: undefined
After:  server.setTimeout(1000).listen() // works

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:03:51 +00:00
4 changed files with 72 additions and 3 deletions

View File

@@ -100,8 +100,8 @@ declare module "bun" {
declare namespace WebAssembly {
interface ValueTypeMap extends Bun.WebAssembly.ValueTypeMap {}
interface GlobalDescriptor<T extends keyof ValueTypeMap = keyof ValueTypeMap>
extends Bun.WebAssembly.GlobalDescriptor<T> {}
interface GlobalDescriptor<T extends keyof ValueTypeMap = keyof ValueTypeMap> extends Bun.WebAssembly
.GlobalDescriptor<T> {}
interface MemoryDescriptor extends Bun.WebAssembly.MemoryDescriptor {}
interface ModuleExportDescriptor extends Bun.WebAssembly.ModuleExportDescriptor {}
interface ModuleImportDescriptor extends Bun.WebAssembly.ModuleImportDescriptor {}

View File

@@ -3807,6 +3807,7 @@ class Http2Server extends net.Server {
if (typeof callback === "function") {
this.on("timeout", callback);
}
return this;
}
updateSettings(settings) {
assertSettings(settings);
@@ -3900,6 +3901,7 @@ class Http2SecureServer extends tls.Server {
if (typeof callback === "function") {
this.on("timeout", callback);
}
return this;
}
updateSettings(settings) {
assertSettings(settings);

View File

@@ -1941,7 +1941,7 @@ test("no assertion failures 3", () => {
],
[
class // Random { // comments /* */ are part of the toString() result
äß /**/
äß /**/
extends /*{*/ TypeError {},
"[class äß extends TypeError]",
],

View File

@@ -0,0 +1,67 @@
import { expect, test } from "bun:test";
import { tls } from "harness";
import * as http2 from "http2";
test("Http2Server.setTimeout returns server instance for method chaining", () => {
const server = http2.createServer();
try {
const result = server.setTimeout(1000);
expect(result).toBe(server);
} finally {
server.close();
}
});
test("Http2Server.setTimeout with callback returns server instance", () => {
const server = http2.createServer();
const callback = () => {};
try {
const result = server.setTimeout(1000, callback);
expect(result).toBe(server);
} finally {
server.close();
}
});
test("Http2Server.setTimeout allows method chaining with close", () => {
const server = http2.createServer();
// This should not throw - chaining should work
expect(() => {
server.setTimeout(1000).close();
}).not.toThrow();
});
test("Http2SecureServer.setTimeout returns server instance for method chaining", () => {
const server = http2.createSecureServer(tls);
try {
const result = server.setTimeout(1000);
expect(result).toBe(server);
} finally {
server.close();
}
});
test("Http2SecureServer.setTimeout with callback returns server instance", () => {
const server = http2.createSecureServer(tls);
const callback = () => {};
try {
const result = server.setTimeout(1000, callback);
expect(result).toBe(server);
} finally {
server.close();
}
});
test("Http2SecureServer.setTimeout allows method chaining with close", () => {
const server = http2.createSecureServer(tls);
// This should not throw - chaining should work
expect(() => {
server.setTimeout(1000).close();
}).not.toThrow();
});