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

x/playground: firing "load" event too early #56953

Open
Deleplace opened this issue Nov 28, 2022 · 3 comments
Open

x/playground: firing "load" event too early #56953

Deleplace opened this issue Nov 28, 2022 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Deleplace
Copy link
Contributor

What version of Go are you using (go version)?

go1.19.2

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Just the web playground

What did you do?

Open Google Chrome
Open the DevTools panel, on the tab Networks
Load the permalink of a playground program e.g. https://go.dev/play/p/ejOfDs_Hg9
Filter the network tab on the snippet ID: ejOfDs_Hg9

What did you expect to see?

The red vertical line (load event) should be after the snippet source code request has finished loading, in the waterfall

What did you see instead?

The red vertical line (load event) is before the snippet source code request, in the waterfall

image

This is a nit, not a serious bug!

Currently, opening a given program's playground permalink loads the page layout HTML, then the JS, then the actual main content which is the program source code. We may want to honor the doc of the load event: "is fired when the whole page has loaded, including all dependent resources".

@gopherbot gopherbot added this to the Unreleased milestone Nov 28, 2022
@Deleplace
Copy link
Contributor Author

For context: I stumbled on this when trying to scrap source code and screenshots of code that I stored in various playgrounds, from their permalinks. When load is fired, the source code area is still empty.

image

For the Go playground specifically, an easy workaround for me (instead of using a headless browser such as chromedp) is to extract the snippet ID from the URL e.g. https://go.dev/play/p/ejOfDs_Hg9 -> ejOfDs_Hg9, and then fetch the raw response of the "share" request e.g. https://go.dev/_/share?id=ejOfDs_Hg9

@seankhliao
Copy link
Member

The same content is available by appending .go to the play url, eg https://go.dev/play/p/ejOfDs_Hg9.go

@Deleplace
Copy link
Contributor Author

That's amazing, thanks for the tip!

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants