mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Fixes #15470
This commit is contained in:
@@ -5765,6 +5765,10 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp
|
||||
return JSValue.jsNumber(0);
|
||||
}
|
||||
|
||||
if (this.config.websocket == null or this.app == null) {
|
||||
return JSValue.jsNumber(0);
|
||||
}
|
||||
|
||||
return JSValue.jsNumber((this.app.?.numSubscribers(topic.slice())));
|
||||
}
|
||||
|
||||
|
||||
@@ -825,3 +825,13 @@ async function connect(server: Server): Promise<void> {
|
||||
clients.push(client);
|
||||
await promise;
|
||||
}
|
||||
|
||||
it("you can call server.subscriberCount() when its not a websocket server", async () => {
|
||||
const server = serve({
|
||||
port: 0,
|
||||
fetch(request, server) {
|
||||
return new Response();
|
||||
},
|
||||
});
|
||||
expect(server.subscriberCount("boop")).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user