Skip to content

Conversation

@kevinwhereby
Copy link
Contributor

@kevinwhereby kevinwhereby commented Jan 14, 2026

Description

Summary:
Ensures all active handles are closed when leaving a room.

Related Issue:
PAN-2373: Gracefully shutdown SDK when local client is kicked from room

Testing

  1. create a simple test app using the WherebyClient in @whereby.com/core and run it in node
import "../dist/agent-util/polyfills.js";
import { WherebyClient } from "@whereby.com/core";

process.on("beforeExit", (code) => {
    // we add this handler to catch a bug in node-wrtc that causes segfaults and invalid pointer errors at shutdown
    // https://github.com/WonderInventions/node-webrtc/issues/35
    process.exit(code);
});

const client = new WherebyClient();
const roomConnection = client.getRoomConnection();
const localMedia = client.getLocalMedia();
roomConnection.initialize({
    isNodeSdk: true,
    roomUrl: process.env.ROOM_URL,
});

async function start() {
    await localMedia.startMedia({ audio: false, video: false });

    // shutdown when we are kicked out
    roomConnection.subscribeToConnectionStatus((status) => {
        if (status === "kicked") {
            setImmediate(() => {
                localMedia.destroy();
                roomConnection.destroy();
                client.destroy();
            });
        }
    });

    // join the room
    try {
        await roomConnection.joinRoom();
        // leave the room if we aren't kicked
        setTimeout(() => {
            localMedia.destroy();
            roomConnection.destroy();
            client.destroy();
        }, 30 * 1000);
    } catch (error) {
        console.error("Could not join room", error);
    }
}

start();
  1. join the same room as a host and run the script. After it joins, wait a few seconds and kick the node participant
  2. see that the node process shuts down correctly

Screenshots/GIFs (if applicable)

Checklist

  • My code follows the project's coding standards.
  • Prefixed the PR title and commit messages with the service or package name
  • I have written unit tests (if applicable).
  • I have updated the documentation (if applicable).
  • By submitting this pull request, I confirm that my contribution is made
    under the terms of the MIT license.

Additional Information

@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: d303c75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@whereby.com/media Minor
@whereby.com/browser-sdk Patch
@whereby.com/core Patch
@whereby.com/assistant-sdk Patch
@whereby.com/react-native-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kevinwhereby
Copy link
Contributor Author

/canary

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from e000bf7 to cfdc146 Compare January 14, 2026 19:21
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby
Copy link
Contributor Author

/canary

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from 2112a1d to 9a0f97f Compare January 15, 2026 11:17
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from 9a0f97f to b24ea43 Compare January 15, 2026 11:28
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from b24ea43 to aa28790 Compare January 15, 2026 13:14
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby
Copy link
Contributor Author

/canary

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from ba7e699 to 7dabaa5 Compare January 15, 2026 13:56
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from 7dabaa5 to 2156b1a Compare January 15, 2026 14:19
@kevinwhereby kevinwhereby changed the title core: disconnect signal when app is no longer active core+media: stop tasks when app is no longer active Jan 15, 2026
@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch 2 times, most recently from aba71a9 to c1263bc Compare January 16, 2026 11:36
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch 2 times, most recently from 097e551 to 1ba04fe Compare January 16, 2026 17:01
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch 4 times, most recently from f9fab4d to 6f20218 Compare January 19, 2026 18:33
@kevinwhereby
Copy link
Contributor Author

/canary

@github-actions
Copy link
Contributor

🚀 The canary releases have been published to npm.

You can test the releases by installing the newly published versions:

pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]
pnpm add @whereby.com/[email protected]

@kevinwhereby kevinwhereby requested a review from a team January 20, 2026 09:15
@kevinwhereby kevinwhereby force-pushed the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch from 6f20218 to d303c75 Compare January 20, 2026 12:36
Copy link
Contributor

@havardholvik havardholvik left a comment

Choose a reason for hiding this comment

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

Works as expected 👍

Copy link
Contributor

@richtrwhereby richtrwhereby left a comment

Choose a reason for hiding this comment

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

LGTM!

@kevinwhereby kevinwhereby merged commit a796b6d into main Jan 22, 2026
3 checks passed
@kevinwhereby kevinwhereby deleted the kevinhanna/pan-2373-gracefully-shutdown-sdk-when-local-client-is-kicked-from branch January 22, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants