diff options
| -rw-r--r-- | packages/bun-types/bun.d.ts | 16 | ||||
| -rw-r--r-- | src/bun.js/api/server.zig | 2 | ||||
| -rw-r--r-- | test/js/bun/websocket/websocket-server.test.ts | 15 |
3 files changed, 25 insertions, 8 deletions
diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 5558e2db7..d5085e739 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -1482,16 +1482,18 @@ declare module "bun" { closeOnBackpressureLimit?: boolean; /** - * Control whether or not ws.publish() should include the ServerWebSocket - * that published the message. This is enabled by default, but it was an API - * design mistake. A future version of Bun will change this default to - * `false` and eventually remove this option entirely. The better way to publish to all is to use {@link Server.publish}. + * Control whether or not ws.publish() should include the `ServerWebSocket` + * that published the message. * - * if `true` or `undefined`, {@link ServerWebSocket.publish} will publish to all subscribers, including the websocket publishing the message. + * As of Bun v0.6.3, this option defaults to `false`. * - * if `false`, {@link ServerWebSocket.publish} will publish to all subscribers excluding the websocket publishing the message. + * In Bun v0.6.2 and earlier, this option defaulted to `true`, but it was an API design mistake. A future version of Bun will eventually remove this option entirely. The better way to publish to all is to use {@link Server.publish}. * - * @default true + * if `true` {@link ServerWebSocket.publish} will publish to all subscribers, including the websocket publishing the message. + * + * if `false` or `undefined`, {@link ServerWebSocket.publish} will publish to all subscribers excluding the websocket publishing the message. + * + * @default false * */ publishToSelf?: boolean; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 2ce7347c0..463e26c0a 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -2980,7 +2980,7 @@ pub const WebSocketServer = struct { /// used by publish() flags: packed struct(u2) { ssl: bool = false, - publish_to_self: bool = true, + publish_to_self: bool = false, } = .{}, pub fn fromJS(globalObject: *JSC.JSGlobalObject, object: JSC.JSValue) ?Handler { diff --git a/test/js/bun/websocket/websocket-server.test.ts b/test/js/bun/websocket/websocket-server.test.ts index 3868d0267..7259fc8b6 100644 --- a/test/js/bun/websocket/websocket-server.test.ts +++ b/test/js/bun/websocket/websocket-server.test.ts @@ -37,6 +37,9 @@ describe("websocket server", () => { var server = serve({ port: 0, websocket: { + // FIXME: update this test to not rely on publishToSelf: true, + publishToSelf: true, + open(ws) { ws.subscribe("all"); }, @@ -115,6 +118,9 @@ describe("websocket server", () => { var server = serve({ port: 0, websocket: { + // FIXME: update this test to not rely on publishToSelf: true, + publishToSelf: true, + open(ws) { ws.subscribe("all"); }, @@ -617,6 +623,9 @@ describe("websocket server", () => { var server = serve({ port: 0, websocket: { + // FIXME: update this test to not rely on publishToSelf: true, + publishToSelf: true, + async open(ws) { // we don't care about the data // we just want to make sure the DOMJIT call doesn't crash @@ -647,6 +656,9 @@ describe("websocket server", () => { var server = serve({ port: 0, websocket: { + // FIXME: update this test to not rely on publishToSelf: true, + publishToSelf: true, + async open(ws) { // we don't care about the data // we just want to make sure the DOMJIT call doesn't crash @@ -908,6 +920,9 @@ describe("websocket server", () => { const server = serve({ port: 0, websocket: { + // FIXME: update this test to not rely on publishToSelf: true, + publishToSelf: true, + open(ws) { server.stop(); ws.subscribe("test"); |
