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/website/go.dev: playground snippets in blog posts fail to run #48011

Closed
delvatt opened this issue Aug 27, 2021 · 5 comments
Closed

x/website/go.dev: playground snippets in blog posts fail to run #48011

delvatt opened this issue Aug 27, 2021 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@delvatt
Copy link

delvatt commented Aug 27, 2021

What is the URL of the page with the issue?

The issue seems to appear on playground code snippets of any article on The Go Blog, like Strings, bytes, runes and characters in Go

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

OS

Linux 5.13.12_1 #1 SMP Wed Aug 18 11:48:14 UTC 2021

What did you expect to see?

Code results output from playground remote server.

What did you see instead?

Error communicating with remote server.
Program exited.

Screenshot

Screenshot_20210827-120509~3

@gopherbot gopherbot added this to the Unreleased milestone Aug 27, 2021
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 27, 2021
@toothrot
Copy link
Contributor

This looks like it is due to the /compile endpoint not existing on go.dev. @rsc

@toothrot
Copy link
Contributor

Rather, it should be requesting to play.golang.org.

@dmitshur dmitshur changed the title x/website:Blog: Playground snippets (Run): "Error communicating with remote server. - Program exited." x/website/go.dev: playground snippets in blog posts fail to run Aug 27, 2021
@gopherbot
Copy link

Change https://golang.org/cl/345749 mentions this issue: x/tools/playground/playground: Fix the problem that the request data is empty

@dmitshur
Copy link
Contributor

dmitshur commented Aug 27, 2021

I think this issue can be fixed by changing go.dev's playground.js script as follows:

-$.ajax('/compile', {
+$.ajax('https://play.golang.org/compile', {

(Source: go.dev/_content/js/playground.js#L126.)

And adding https://play.golang.org to go.dev Content Security Policy's connect-src field:

 "connect-src": {
 	"'self'",
	"https://golang.org",
+	"https://play.golang.org", // For running playground snippets on the blog.

(Source: cmd/golangorg/csp.go#L44.)

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 27, 2021
@gopherbot
Copy link

Change https://golang.org/cl/346212 mentions this issue: blog: fix code playground failed to run

@golang golang locked and limited conversation to collaborators Sep 3, 2022
passionSeven added a commit to passionSeven/website that referenced this issue Oct 18, 2022
Fixes golang/go#48011

Change-Id: I6ae0c3c3696f5e88258f39532137bfc0b5ec31ee
Reviewed-on: https://go-review.googlesource.com/c/website/+/346212
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Website-Publish: DO NOT USE <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants