UBERF-7118: Fix upgrade/refresh on reconnect (#5704)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-05-31 00:31:12 +07:00 committed by GitHub
parent 3e913c9db7
commit 42d8c4582c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 5 deletions

View File

@ -276,10 +276,10 @@ export function startHttpServer (
if (webSocketData.session instanceof Promise) {
void webSocketData.session.then((s) => {
if ('upgrade' in s || 'error' in s) {
if ('error' in s) {
ctx.error('error', { error: s.error?.message, stack: s.error?.stack })
}
if ('error' in s) {
ctx.error('error', { error: s.error?.message, stack: s.error?.stack })
}
if ('upgrade' in s) {
void cs
.send(ctx, { id: -1, result: { state: 'upgrading', stats: (s as any).upgradeInfo } }, false, false)
.then(() => {

View File

@ -126,7 +126,8 @@ export function startUWebsocketServer (
mode: data.payload.extra?.mode,
model: data.payload.extra?.model
}
data.connectionSocket = createWebSocketClientSocket(wrData, ws, data)
const cs = createWebSocketClientSocket(wrData, ws, data)
data.connectionSocket = cs
data.session = sessions.addSession(
ctx,
@ -138,6 +139,21 @@ export function startUWebsocketServer (
undefined,
accountsUrl
)
if (data.session instanceof Promise) {
void data.session.then((s) => {
if ('error' in s) {
ctx.error('error', { error: s.error?.message, stack: s.error?.stack })
}
if ('upgrade' in s) {
void cs
.send(ctx, { id: -1, result: { state: 'upgrading', stats: (s as any).upgradeInfo } }, false, false)
.then(() => {
cs.close()
})
}
})
}
},
message: (ws, message, isBinary) => {
const data = ws.getUserData()