From a5246344fa40201931d5ffd274ef76d810759106 Mon Sep 17 00:00:00 2001 From: robobun Date: Fri, 30 Jan 2026 13:23:04 -0800 Subject: [PATCH] fix(types): Socket.reload() now correctly expects { socket: handler } (#26291) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Fix type definition for `Socket.reload()` to match runtime behavior - The runtime expects `{ socket: handler }` but types previously accepted just `handler` ## Test plan - [x] Added regression test `test/regression/issue/26290.test.ts` - [x] Verified test passes with `bun bd test` Fixes #26290 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Alistair Smith --- packages/bun-types/bun.d.ts | 4 ++-- test/integration/bun-types/fixture/tcp.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index f8b6991e48..80a7ec66f7 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -5679,7 +5679,7 @@ declare module "bun" { * * This will apply to all sockets from the same {@link Listener}. it is per socket only for {@link Bun.connect}. */ - reload(handler: SocketHandler): void; + reload(options: Pick, "socket">): void; /** * Get the server that created this socket @@ -6022,7 +6022,7 @@ declare module "bun" { stop(closeActiveConnections?: boolean): void; ref(): void; unref(): void; - reload(options: Pick, "socket">): void; + reload(options: Pick, "socket">): void; data: Data; } interface TCPSocketListener extends SocketListener { diff --git a/test/integration/bun-types/fixture/tcp.ts b/test/integration/bun-types/fixture/tcp.ts index fe1b66a648..e8f42689a1 100644 --- a/test/integration/bun-types/fixture/tcp.ts +++ b/test/integration/bun-types/fixture/tcp.ts @@ -145,3 +145,23 @@ listener.reload({ // ...listener. }, }); + +// Test Socket.reload() type signature (issue #26290) +// The socket instance's reload() method should also accept { socket: handler } +await Bun.connect({ + data: { arg: "asdf" }, + socket: { + open(socket) { + // Socket.reload() should accept { socket: handler }, not handler directly + socket.reload({ + socket: { + open() {}, + data() {}, + }, + }); + }, + data() {}, + }, + hostname: "localhost", + port: 1, +});