From 981762406b09f12e70eaf7f382f2c5d8c9b8f5df Mon Sep 17 00:00:00 2001 From: Alex Shepeliev Date: Fri, 5 Dec 2025 22:22:59 +0200 Subject: [PATCH] Fix auto response configuration is not set after upgrade request --- packages/core/src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 69bec8b..5da03f2 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -238,6 +238,12 @@ export abstract class Actor extends DurableObject { // 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); @@ -251,12 +257,6 @@ export abstract class Actor extends DurableObject { } } - // 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