Skip to content

Conversation

@trivikr
Copy link
Member

@trivikr trivikr commented Feb 3, 2023

Issue

Fixes #3922

Description

Closes sockets on WebSocketHandler.destroy()

Testing

CI


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr changed the title chore(middleware-sk-transcribe-streaming): close sockets on WebSocketHandler.destroy() chore(middleware-sdk-transcribe-streaming): close sockets on WebSocketHandler.destroy() Feb 3, 2023
@trivikr trivikr force-pushed the websocket-handler-destroy branch from d9032e2 to 445c315 Compare February 3, 2023 16:14
@trivikr trivikr force-pushed the websocket-handler-destroy branch from 0eb4d4d to c54d772 Compare February 3, 2023 17:19
@trivikr trivikr changed the title chore(middleware-sdk-transcribe-streaming): close sockets on WebSocketHandler.destroy() fix(middleware-sdk-transcribe-streaming): close sockets on WebSocketHandler.destroy() Feb 3, 2023
@trivikr trivikr marked this pull request as ready for review February 3, 2023 20:26
@trivikr trivikr requested a review from a team as a code owner February 3, 2023 20:26
@trivikr trivikr force-pushed the websocket-handler-destroy branch from b83b29c to b75951f Compare February 3, 2023 20:57
/**
* Removes all closing/closed sockets from the socket pool for URL.
*/
private removeNotUsableSockets(url: string): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to removeClosedSockets?

Copy link
Member Author

@trivikr trivikr Feb 3, 2023

Choose a reason for hiding this comment

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

It was originally named removeClosedSockets
It removes Closing sockets too, that's why I'd renamed it from Closed to NotUsable.

handler.destroy();

// Verify that socket.close() is called
expect(socket.readyState).toBe(WebSocket.CLOSING);
Copy link
Contributor

Choose a reason for hiding this comment

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

on what timing does this transition to WebSocket.CLOSED?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried timeouts of 1s and 5s, but the state was still closing.
That's why I updated source code to remove sockets with closing state, and verified state to be closing.

@trivikr trivikr merged commit 3a0cc76 into aws:main Feb 3, 2023
@trivikr trivikr deleted the websocket-handler-destroy branch February 3, 2023 23:59
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling .destroy() doesn't destroy the transcribe client

2 participants