Skip to content

Commit

Permalink
c12: fix: prevent the client from caching the server responses (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfelixrico authored Apr 3, 2024
1 parent d649c5c commit 82c5848
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client/src/modules/pad-socket/pad-events-v2.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function prepareCatchUp(roomId: string) {

async function startCatchUp() {
const lengthResp = await api.get<{ length: number }>(
`/room/${roomId}/event/length`
`/room/${roomId}/event/length`,
{
signal: abortCtrl.signal,
}
)
const length = lengthResp.data.length

Expand Down Expand Up @@ -52,11 +55,11 @@ function prepareCatchUp(roomId: string) {
console.debug('Finished fetching %d to %d', start, end)
}

console.debug('Finished catching up to %s')
console.debug('Finished catching up')
events$.complete()
} catch (e) {
if (isCancel(e)) {
console.debug('Catch up cancelled for room %s', roomId, length)
console.debug('Catch up cancelled for room %s', roomId)
events$.complete()
return
}
Expand Down
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dotenv": "^16.4.5",
"express": "^4.18.3",
"nanoid": "^3.0.0",
"nocache": "^4.0.0",
"socket.io": "^4.7.4"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import { createServer } from 'http'
import { Server } from 'socket.io'
import { socketIOHandler } from './socket-controllers/socket.controller'
import roomService from './services/room.service'
import nocache from 'nocache'

const app = express()
const server = createServer(app)
const io = new Server(server)

app.use(nocache())

app.get('/', (_, res) => {
res.send('Hello World')
})
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4427,6 +4427,11 @@ negotiator@0.6.3:
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==

nocache@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/nocache/-/nocache-4.0.0.tgz#d6c6f34bee4600f63f852dccfeb29c9a96cf85c0"
integrity sha512-AntnTbmKZvNYIsTVPPwv7dfZdAfo/6H/2ZlZACK66NAOQtIApxkB/6pf/c+s+ACW8vemGJzUCyVTssrzNUK6yQ==

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down

0 comments on commit 82c5848

Please sign in to comment.