AlexanderJGael / harmony_hub

0 stars 0 forks source link

Chat Feature (Socket.io) #1

Open AlexanderJGael opened 7 months ago

AlexanderJGael commented 7 months ago

To run: clone repo to local machine navigate to folder containing server.js run: npm i to install dependencies run: DEBUG=socket.io:* node server.js navigate to http://localhost:3001/chat enter a message and send

expected behvior: message is logged to database and appears on screen

actual behavior: message is sent, but not created in database. No message appears on screen.

Issue: DEBUG=socket.io:* node server.js

socket.io:server initializing namespace / +0ms socket.io:server creating engine.io instance with opts {"cleanupEmptyChildNamespaces":false,"path":"/socket.io"} +0ms socket.io:server attaching client serving req handler +1ms Now listening on https://localhost:3001 Executing (default): SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = 'Sessions' AND TABLE_SCHEMA = 'users_db' Executing (default): SHOW INDEX FROM Sessions { Session: Session } Database synced Executing (default): SELECT sid, expires, data, createdAt, updatedAt FROM Sessions AS Session WHERE Session.sid = 'hAGbSdKv2rJwBP6nB102S5qv-7B_Gtwv'; Executing (default): UPDATE Sessions SET expires=?,updatedAt=? WHERE sid = ? Executing (default): SELECT sid, expires, data, createdAt, updatedAt FROM Sessions AS Session WHERE Session.sid = 'hAGbSdKv2rJwBP6nB102S5qv-7B_Gtwv'; Executing (default): SELECT sid, expires, data, createdAt, updatedAt FROM Sessions AS Session WHERE Session.sid = 'hAGbSdKv2rJwBP6nB102S5qv-7B_Gtwv'; Executing (default): UPDATE Sessions SET expires=?,updatedAt=? WHERE sid = ? Executing (default): UPDATE Sessions SET expires=?,updatedAt=? WHERE sid = ? Executing (default): SELECT sid, expires, data, createdAt, updatedAt FROM Sessions AS Session WHERE Session.sid = 'hAGbSdKv2rJwBP6nB102S5qv-7B_Gtwv'; Executing (default): UPDATE Sessions SET expires=?,updatedAt=? WHERE sid = ? Executing (default): SELECT sid, expires, data, createdAt, updatedAt FROM Sessions AS Session WHERE Session.sid = 'hAGbSdKv2rJwBP6nB102S5qv-7B_Gtwv'; Executing (default): UPDATE Sessions SET expires=?,updatedAt=? WHERE sid = ? Executing (default): SELECT sid, expires, data, createdAt, updatedAt FROM Sessions AS Session WHERE Session.sid = 'hAGbSdKv2rJwBP6nB102S5qv-7B_Gtwv'; Executing (default): UPDATE Sessions SET expires=?,updatedAt=? WHERE sid = ? socket.io:server serve client source 304 +22s socket.io:server incoming connection with id qH8Q0UUewoOKBPRXAAAA +39ms socket.io:client connecting to namespace / +0ms socket.io:namespace adding socket to nsp / +0ms socket.io:socket socket connected - writing packet +0ms socket.io:socket join room lLUnH0td_ElmMMD1AAAB +0ms socket connected: lLUnH0td_ElmMMD1AAAB socket.io:socket got packet {"type":2,"nsp":"/","data":["chat message","Hello"]} +6s socket.io:socket emitting event ["chat message","Hello"] +0ms socket.io:socket dispatching an event ["chat message","Hello"] +0ms message: Hello Failed to create message TypeError: Cannot read properties of undefined (reading 'create') at Socket. (/Users/alexanderjgael/Development/Bootcamp/Challenges/group_project2/server.js:60:48) at Socket.emit (node:events:519:28) at Socket.emitUntyped (/Users/alexanderjgael/Development/Bootcamp/Challenges/group_project2/node_modules/socket.io/dist/typed-events.js:69:22) at /Users/alexanderjgael/Development/Bootcamp/Challenges/group_project2/node_modules/socket.io/dist/socket.js:704:39 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) Error name: TypeError Error message: Cannot read properties of undefined (reading 'create')