Skip to content

fix puterjs throwing errors after consuming message events not meant for it#1612

Merged
jelveh merged 2 commits intoHeyPuter:mainfrom
velzie:main
Sep 25, 2025
Merged

fix puterjs throwing errors after consuming message events not meant for it#1612
jelveh merged 2 commits intoHeyPuter:mainfrom
velzie:main

Conversation

@velzie
Copy link
Copy Markdown
Contributor

@velzie velzie commented Sep 24, 2025

puter.js uses message events to communicate between the Puter GUI and the app. However, not all message events that puterjs receives are sent from the GUI, they can be sent by the app itself, a subframe of the app, or even an external browser extension messaging with a content script (this is quite common). Other than these cases that I fixed, puter generally checks for the existence of msg and error before doing anything with the data, so it isn't a huge deal. The key msg is somewhat common though, so there's still a chance of it consuming messages that weren't sent from the GUI. There could probably be a namespaced key like puter_message so that this doesn't happen again in the future. I didn't implement this here because there's quite a few places where postmessage was used and there's no abstraction over it so it would get messy, but if that section is ever rewritten or revisited this should be kept in mind

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 24, 2025

CLA assistant check
All committers have signed the CLA.

@jelveh jelveh merged commit 8b9fefa into HeyPuter:main Sep 25, 2025
4 checks passed
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.

3 participants