Skip to content
Open
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
12 changes: 6 additions & 6 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ export abstract class Actor<E> extends DurableObject<E> {
// If the request route is `/ws` then we should upgrade the connection to a WebSocket
// Get configuration from the static property
const config = (this.constructor as typeof Actor).configuration(request);

// Autoresponse in sockets allows clients to send a ping message and receive a pong response
// without waking the durable object up from hibernation.
if (config?.sockets?.autoResponse) {
this.ctx.setWebSocketAutoResponse(new WebSocketRequestResponsePair(config.sockets.autoResponse.ping, config.sockets.autoResponse.pong));
}

// Parse the URL to check if the path component matches the upgradePath
const url = new URL(request.url);
Expand All @@ -251,12 +257,6 @@ export abstract class Actor<E> extends DurableObject<E> {
}
}

// Autoresponse in sockets allows clients to send a ping message and receive a pong response
// without waking the durable object up from hibernation.
if (config?.sockets?.autoResponse) {
this.ctx.setWebSocketAutoResponse(new WebSocketRequestResponsePair(config.sockets.autoResponse.ping, config.sockets.autoResponse.pong));
}

// Wait for setName to be called before running onRequest
if (!this._setNameCalled) {
// If setName hasn't been called yet, wait for it
Expand Down