Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable hibernation properly #134

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/durableObjects/ChatRoom.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export class ChatRoom extends Server<Env> {
env: Env
db: DrizzleD1Database<Record<string, never>> | null

// static options = { hibernate: true }

constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env)
this.env = env
Expand All @@ -46,12 +48,12 @@ export class ChatRoom extends Server<Env> {
log({ eventName: 'onStart', meetingId })
this.db = getDb(this)
// TODO: make this a part of partyserver
this.ctx.setWebSocketAutoResponse(
new WebSocketRequestResponsePair(
JSON.stringify({ type: 'partyserver-ping' }),
JSON.stringify({ type: 'partyserver-pong' })
)
)
// this.ctx.setWebSocketAutoResponse(
// new WebSocketRequestResponsePair(
// JSON.stringify({ type: 'partyserver-ping' }),
// JSON.stringify({ type: 'partyserver-pong' })
// )
// )
}

async onConnect(
Expand Down
20 changes: 10 additions & 10 deletions app/hooks/useRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ export default function useRoom({
}
}, [websocket])

// setup a simple ping pong
useEffect(() => {
const interval = setInterval(() => {
websocket.send(
JSON.stringify({ type: 'partyserver-ping' } satisfies ClientMessage)
)
}, 5000)

return () => clearInterval(interval)
}, [websocket])
// // setup a simple ping pong
// useEffect(() => {
// const interval = setInterval(() => {
// websocket.send(
// JSON.stringify({ type: 'partyserver-ping' } satisfies ClientMessage)
// )
// }, 5000)
//
// return () => clearInterval(interval)
// }, [websocket])

const identity = useMemo(
() => roomState.users.find((u) => u.id === websocket.id),
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"cookie": "^0.6.0",
"drizzle-orm": "^0.33.0",
"nanoid": "^5.0.7",
"partyserver": "^0.0.51",
"partyserver": "^0.0.57",
"partysocket": "^1.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down