Skip to content

Commit

Permalink
[UTS] Don’t use private APIs in closeAndFinish
Browse files Browse the repository at this point in the history
This is part of removing some common private API usage for the unified
test suite.

It’s not clear to me why these private APIs were required. Even
`nextTick`, which had a comment saying that it is needed by
“channelattach_publish_invalid etc” — removing the `nextTick` does not
seem to affect those tests (although 4a90e75, which introduced the
`nextTick` usage, does describe it as a “race” so perhaps we need to see
if failures emerge over time).
  • Loading branch information
lawrence-forooghian committed Jul 25, 2024
1 parent 73b6b4c commit 8e37ad0
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions test/common/modules/shared_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,27 +248,16 @@ define([
}

_callbackOnClose(realtime, callback) {
this.recordPrivateApi('read.connectionManager.activeProtocol');
if (!realtime.connection.connectionManager.activeProtocol) {
this.recordPrivateApi('call.Platform.nextTick');
platform.Config.nextTick(function () {
realtime.close();
callback();
});
if (realtime.connection.state === 'closed' || realtime.connection.state === 'failed') {
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. */
this.recordPrivateApi('call.Platform.nextTick');
platform.Config.nextTick(function () {
realtime.close();
});

realtime.close();
}

closeAndFinishSeveral(done, realtimeArray, e) {
Expand Down

0 comments on commit 8e37ad0

Please sign in to comment.