Skip to content

Change the 'is-ready' postMessage pairs to 'ready:request' and 'ready:response' to be more explicit #5148

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

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

canova
Copy link
Member

@canova canova commented Oct 1, 2024

Edit after updating the PR:
I have changed the postMessage names directly now to 'ready:request' and 'ready:response' to be more explicit.

Before update:
This changes the is-ready message handling that comes from postMessage. I needed this for a Chrome extension I was working on. But in their extension API you have to be in the same window while sending this message. That's why when is-ready returns a message with the same name to itself, it creates an infinite loop. I changed the name from is-ready to ready when notifying the profiler is ready.

@gregtatum I wanted to get your feedback since you implemented this feature initially for your work. I would prefer to always send ready instead of is-ready but that would probably break your use case. So that's why I went with a non-breaking usage where I check if the windows are the same and if so, send a message with a different name. Let me know what you think!

@canova canova requested a review from gregtatum October 1, 2024 14:28
@canova canova force-pushed the postmessage-infinite-loop branch from 90370e5 to 76f7e78 Compare October 1, 2024 14:28
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.56%. Comparing base (1170042) to head (0d38aa6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5148   +/-   ##
=======================================
  Coverage   88.56%   88.56%           
=======================================
  Files         307      307           
  Lines       27936    27936           
  Branches     7560     7560           
=======================================
+ Hits        24741    24742    +1     
+ Misses       2978     2977    -1     
  Partials      217      217           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@julienw
Copy link
Contributor

julienw commented Oct 2, 2024

Ideally i'd use ready:request and ready:response, something like that. But indeed it is a breaking update, it would be good to know if this can be easily changed on your side @gregtatum :-)

@fqueze
Copy link
Contributor

fqueze commented Oct 7, 2024

I will need to change https://github.com/fqueze/usb-power-profiling/blob/main/index.html#L361 too.

@gregtatum
Copy link
Member

I've been afk for personal stuff these last few weeks, I can look at this soon, but feel free to merge without me.

@gregtatum
Copy link
Member

Please change it to what makes most sense for the cleanest implementation, and I can easily update the message name when you merge. Mine's easy to change.

@canova canova force-pushed the postmessage-infinite-loop branch from 76f7e78 to 73a8972 Compare October 16, 2024 12:20
@canova canova changed the title Avoid posting a message back for 'is-ready' with the same name if windows are the same Change the 'is-ready' postMessage pairs to 'ready:request' and 'ready:response' to be more explicit Oct 16, 2024
@canova
Copy link
Member Author

canova commented Oct 16, 2024

Thanks for the feedback @gregtatum! And thanks for the suggestion @julienw on the message names. I updated the PR and changed the is-ready pairs to ready:request and ready:response.

Please let me know what you think!

@canova canova force-pushed the postmessage-infinite-loop branch from 73a8972 to 0d38aa6 Compare October 16, 2024 12:23
@canova canova requested a review from julienw October 16, 2024 12:29
Copy link
Member

@gregtatum gregtatum left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

lgtm as well!

@canova canova merged commit f22ab2c into firefox-devtools:main Oct 22, 2024
18 checks passed
@canova canova deleted the postmessage-infinite-loop branch October 22, 2024 09:12
@canova
Copy link
Member Author

canova commented Oct 24, 2024

Note that I'm deploying in a bit today. So we would need to update the places where we use this message.

@canova canova mentioned this pull request Oct 24, 2024
canova added a commit that referenced this pull request Oct 24, 2024
[Markus Stange] Fix links to setup-startup-profiling.py post monorepo
migration. (#5162)
[Greg Tatum] Fix marker-only compare profiles (#5130)
[Greg Tatum] Copy over the profile meta when merging profiles (#5131)
[Nazım Can Altınova] Change the 'is-ready' postMessage pairs to
'ready:request' and 'ready:response' to be more explicit (#5148)
[Julien Wajsberg] Fix timestamp issues in local tests (#5167)

Also thanks to our localizers for contributing:
fur: Fabio Tomat
canova added a commit to canova/usb-power-profiling that referenced this pull request Oct 24, 2024
This is changed in firefox-devtools/profiler#5148.
Previously we were using 'is-ready' for both the request and the
response. Now we are using two distinct messages on both for clarity.
canova added a commit to canova/taskcluster-tools that referenced this pull request Oct 24, 2024
This is changed in firefox-devtools/profiler#5148.
Previously we were using 'is-ready' for both the request and the
response. Now we are using two distinct messages on both for clarity.
fqueze pushed a commit to fqueze/usb-power-profiling that referenced this pull request Oct 24, 2024
…API (#8)

This is changed in firefox-devtools/profiler#5148.
Previously we were using 'is-ready' for both the request and the
response. Now we are using two distinct messages on both for clarity.
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.

4 participants