Skip to content

fix: terminate process when WebSocket connection to Stream Deck closes#150

Open
nekename wants to merge 2 commits intoelgatosf:mainfrom
nekename:patch-1
Open

fix: terminate process when WebSocket connection to Stream Deck closes#150
nekename wants to merge 2 commits intoelgatosf:mainfrom
nekename:patch-1

Conversation

@nekename
Copy link
Copy Markdown

@nekename nekename commented Apr 9, 2026

Hello!

This PR contains a simple patch to terminate the plugin process when the WebSocket connection to Stream Deck closes. This ensures that if Stream Deck wasn't able to terminate the plugin process cleanly on exit (e.g. due to Stream Deck being SIGKILLed), it will terminate itself automatically when the WebSocket server is no longer reachable.

Thanks :)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 6fe9bdf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@GeekyEggo
Copy link
Copy Markdown
Member

Hi @nekename, I've confirmed with the Stream Deck Core team, and they don't have any concerns (regarding the connection / process management) with this being added — once the tests are fixed, we'll be happy to merge this in.

@nekename
Copy link
Copy Markdown
Author

Thanks. I'm not too familiar with what's happening with the tests: should I just skip process.exit() when running in the mock environment, so that it has time to call the listeners that it says aren't being called before the mock server dies? How do I detect when it's running in the mock environment?

@GeekyEggo
Copy link
Copy Markdown
Member

GeekyEggo commented Apr 15, 2026

I believe the issue is the new process.exit() is preventing an assertion happening within a test, which is causing the test suite to mark the test as invalid — as a fix, you should be able to stub process.exit() to prevent exiting within connection.test.ts, specifically within the beforeEach call, e.g.

// Re-import the connection to ensure a fresh state.
beforeEach(async () => {
+	// @ts-expect-error: prevent process.exit() from exiting
+	vi.spyOn(process, "exit").mockImplementation(() => {
+		/* no-op */
+	});

	//...
});

@nekename
Copy link
Copy Markdown
Author

I've added that fix in, but the workflow requires approval to run. Hopefully the tests pass now

@GeekyEggo
Copy link
Copy Markdown
Member

The latest changes look good — there are some open discussions internally before we're 100% confident with merging this in. I'll keep you posted as they progress.

@nekename
Copy link
Copy Markdown
Author

Thanks. I believe this should be fine as plugin SDKs in native languages like C# or Rust tend to (some work otherwise) block on a receive loop from the WebSocket on the main thread, meaning the program exits once the WebSocket is closed.

@GeekyEggo
Copy link
Copy Markdown
Member

Thanks for your patience @nekename. After some discussion internally, we'd like to make a few additions to this before it lands in main; could I ask you to re-submit a PR to websocket-onclose please so we can make the additions.

@nekename
Copy link
Copy Markdown
Author

If you need to make any changes, I've left 'Allow edits from maintainers' enabled on this PR, so you should be able to just push to my branch. If you still need me to reopen this against websocket-onclose let me know

@GeekyEggo
Copy link
Copy Markdown
Member

That's even better, thank you — please ignore the websocket-onclose branch, we'll push changes to the fork.

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.

2 participants