-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix: Check worker event data has iterator #10755
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Skipped Deployments
|
|
apps/gamification/utils/worker.ts
Outdated
reject(data.error) | ||
} else { | ||
resolve(data.result) | ||
if (typeof e?.data?.[Symbol.iterator] === 'function') { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
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
e?.data
is an array before destructuring it into[eId, data]
.data.success
property.