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: Check worker event data has iterator #10755

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

memoyil
Copy link
Collaborator

@memoyil memoyil commented Sep 28, 2024


PR-Codex overview

This PR focuses on improving the handling of messages received in web workers by adding a check to ensure the data received is an array before destructuring it. This change enhances the robustness of the code by preventing potential errors when processing unexpected message formats.

Detailed summary

  • Added a check to verify if e?.data is an array before destructuring it into [eId, data].
  • Maintained the existing logic for resolving or rejecting the promise based on the data.success property.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Sep 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gamification ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 29, 2024 5:21am
web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 29, 2024 5:21am
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
aptos-web ⬜️ Ignored (Inspect) Visit Preview Sep 29, 2024 5:21am
blog ⬜️ Ignored (Inspect) Visit Preview Sep 29, 2024 5:21am
bridge ⬜️ Ignored (Inspect) Visit Preview Sep 29, 2024 5:21am
games ⬜️ Ignored (Inspect) Visit Preview Sep 29, 2024 5:21am
uikit ⬜️ Ignored (Inspect) Visit Preview Sep 29, 2024 5:21am

Copy link

changeset-bot bot commented Sep 28, 2024

⚠️ No Changeset found

Latest commit: 3c02630

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

reject(data.error)
} else {
resolve(data.result)
if (typeof e?.data?.[Symbol.iterator] === 'function') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can check with Array.isArray?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done 👍 , I was thinking about more general check but you are right isArray is sufficent in this case since the messages that app pushed are an array

@chefjackson chefjackson merged commit ced738e into develop Sep 30, 2024
19 checks passed
@chefjackson chefjackson deleted the feature/fix_check_worker_data_has_iterator branch September 30, 2024 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants