From 055a8d7c88d385cac68690748f6dccf65439135f Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Thu, 27 Jun 2024 09:31:10 -0300 Subject: [PATCH] =?UTF-8?q?WIP=20don=E2=80=99t=20use=20private=20APIs=20in?= =?UTF-8?q?=20closeAndFinish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/common/modules/shared_helper.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/common/modules/shared_helper.js b/test/common/modules/shared_helper.js index 3663191f2..9fb843c13 100644 --- a/test/common/modules/shared_helper.js +++ b/test/common/modules/shared_helper.js @@ -226,20 +226,18 @@ define([ } _callbackOnClose(realtime, callback) { - this.recordPrivateApi('read.connectionManager.activeProtocol'); - if (!realtime.connection.connectionManager.activeProtocol) { + if (realtime.connection.state === 'closed' || realtime.connection.state === 'failed') { this.recordPrivateApi('call.Platform.nextTick'); platform.Config.nextTick(function () { - realtime.close(); callback(); }); return; } - this.recordPrivateApi('read.connectionManager.activeProtocol.transport'); - this.recordPrivateApi('listen.transport.disposed'); - realtime.connection.connectionManager.activeProtocol.transport.on('disposed', function () { + + realtime.connection.once(['closed', 'failed'], function () { callback(); }); + /* wait a tick before closing in order to avoid the final close * happening synchronously in a publish/attach callback, which * complicates channelattach_publish_invalid etc. */