Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/transport stopped flag #12423

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/transport/src/transports/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export abstract class AbstractTransport extends TypedEmitter<{
/**
* once transport has been stopped, it does not emit any events
*/
protected stopped = false;
protected stopped = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if stopped is the best name, inited ? running?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for dispose and disposed

/**
* once transport is listening, it will be emitting TRANSPORT.UPDATE events
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/transport/src/transports/abstractApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export abstract class AbstractApiTransport extends AbstractTransport {
public init() {
return this.scheduleAction(async () => {
const handshakeRes = await this.sessionsClient.handshake();
this.stopped = !handshakeRes.success;

return handshakeRes.success
? this.success(undefined)
Expand Down Expand Up @@ -118,7 +119,7 @@ export abstract class AbstractApiTransport extends AbstractTransport {
const openDeviceResult = await this.api.openDevice(path, reset);

if (!openDeviceResult.success) {
if (this.listenPromise) {
if (this.listenPromise[path]) {
this.listenPromise[path].resolve(openDeviceResult);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/transport/src/transports/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export class BridgeTransport extends AbstractTransport {
this.isOutdated = versionUtils.isNewer(this.latestVersion, this.version);
}

this.stopped = false;

return this.success(undefined);
});
}
Expand Down
Loading