Skip to content

Fix for the race condition in Tab channel#2

Open
vigneswaranm wants to merge 1 commit intovitkarpov:masterfrom
vigneswaranm:patch-1
Open

Fix for the race condition in Tab channel#2
vigneswaranm wants to merge 1 commit intovitkarpov:masterfrom
vigneswaranm:patch-1

Conversation

@vigneswaranm
Copy link
Copy Markdown

No description provided.

@vitkarpov
Copy link
Copy Markdown
Owner

@vigneswaranm First of all, thank you for the contribution! 👍 You're the first one actually 😃 Do you use the library in production?

Copy link
Copy Markdown
Owner

@vitkarpov vitkarpov left a comment

Choose a reason for hiding this comment

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

First glance, some comments.
Haven't understood the race condition yet, could you elaborate it on your example?

* The below code solves the problem
*/
if (data.key === channelId) {
var data = JSON.parse(data.newValue) || {};
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is a newValue here? 🤔 Do we actually have it in data?

if (data.channelId === channelId) {
window.parent.postMessage(data.message, '*');
window.localStorage.removeItem(channelId);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe we could refactor this a little bit and move to a function (within another commit), so the diff could be more relevant?

@vitkarpov
Copy link
Copy Markdown
Owner

@vigneswaranm ping, can you explain the issue, please? Didn't get the problem so far.

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