Skip to content

Commit 0661077

Browse files
committed
Checking if last message was login before send reset on verifyConnectivity
1 parent a525084 commit 0661077

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

packages/bolt-connection/src/bolt/bolt-protocol-v1.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default class BoltProtocol {
7676
this._log = log
7777
this._onProtocolError = onProtocolError
7878
this._fatalError = null
79+
this._lastMessageSignature = null
7980
}
8081

8182
/**
@@ -353,6 +354,8 @@ export default class BoltProtocol {
353354
this._log.debug(`C: ${message}`)
354355
}
355356

357+
this._lastMessageSignature = message.signature
358+
356359
this.packer().packStruct(
357360
message.signature,
358361
message.fields.map(field => this.packer().packable(field))
@@ -366,6 +369,10 @@ export default class BoltProtocol {
366369
}
367370
}
368371

372+
isLastMessageLogin () {
373+
return this._lastMessageSignature === 0x01
374+
}
375+
369376
/**
370377
* Notifies faltal erros to the observers and mark the protocol in the fatal error state.
371378
* @param {Error} error The error

packages/bolt-connection/src/connection-provider/connection-provider-pooled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class PooledConnectionProvider extends ConnectionProvider {
123123
const connection = await this._connectionPool.acquire(address)
124124
const serverInfo = new ServerInfo(connection.server, connection.protocol().version)
125125
try {
126-
if (!connection._firstUsage) {
126+
if (!connection._firstUsage && !connection.protocol().isLastMessageLogin()) {
127127
await connection.resetAndFlush()
128128
}
129129
} finally {

packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('.verifyConnectivityAndGetServerInfo()', () => {
251251
const create = (address, release) => {
252252
const connection = new FakeConnection(address, release, server)
253253
connection.protocol = () => {
254-
return { version: protocolVersion }
254+
return { version: protocolVersion, isLastMessageLogin() { return false } }
255255
}
256256
connection.resetAndFlush = resetAndFlush
257257
if (releaseMock) {

packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,8 @@ class FakeConnection extends Connection {
31123112

31133113
protocol () {
31143114
return {
3115-
version: this._protocolVersion
3115+
version: this._protocolVersion,
3116+
isLastMessageLogin: () => this._firstUsage
31163117
}
31173118
}
31183119
}

0 commit comments

Comments
 (0)