@@ -4,6 +4,7 @@ import { Server, type Socket as ServerSocket } from "socket.io";
44import { io as ioc , type Socket as ClientSocket } from "socket.io-client" ;
55import { Pool } from "pg" ;
66import { createAdapter } from "../lib" ;
7+ import { randomUUID } from "node:crypto" ;
78
89export function times ( count : number , done : ( err ?: Error ) => void ) {
910 let i = 0 ;
@@ -25,14 +26,15 @@ export function shouldNotHappen(done: (err?: Error) => void) {
2526 return ( ) => done ( new Error ( "should not happen" ) ) ;
2627}
2728
28- function createServerAndClient ( pool : Pool ) {
29+ function createServerAndClient ( pool : Pool , channelPrefix : string ) {
2930 const httpServer = createServer ( ) ;
3031 const io = new Server ( httpServer , {
3132 adapter : createAdapter ( pool , {
3233 tableName : "events" ,
34+ channelPrefix,
3335 errorHandler ( err ) {
3436 console . log ( "adapter error" , err ) ;
35- }
37+ } ,
3638 } ) ,
3739 } ) ;
3840
@@ -78,6 +80,8 @@ export async function setup() {
7880 password : "changeit" ,
7981 } ) ;
8082
83+ const channelPrefix = randomUUID ( ) ;
84+
8185 await pool . query (
8286 `
8387 CREATE TABLE IF NOT EXISTS events (
@@ -90,9 +94,9 @@ export async function setup() {
9094 ) ;
9195
9296 const results = await Promise . all ( [
93- createServerAndClient ( pool ) ,
94- createServerAndClient ( pool ) ,
95- createServerAndClient ( pool ) ,
97+ createServerAndClient ( pool , channelPrefix ) ,
98+ createServerAndClient ( pool , channelPrefix ) ,
99+ createServerAndClient ( pool , channelPrefix ) ,
96100 ] ) ;
97101
98102 const servers = results . map ( ( { io } ) => io ) ;
0 commit comments