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/pkgsite: incorrect example output #58476

Closed
soroushj opened this issue Feb 11, 2023 · 2 comments
Closed

x/pkgsite: incorrect example output #58476

soroushj opened this issue Feb 11, 2023 · 2 comments

Comments

@soroushj
Copy link

What is the URL of the page with the issue?

https://pkg.go.dev/github.com/soroushj/gosyphus@v1.0.0#example-package

What is your user agent?

Chrome 110 on Linux (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36)

Screenshot

pkgsite-issue

What did you do?

Ran the first package example.

What did you expect to see?

This output:

calculating the answer
calculating the answer
calculating the answer
the answer is 42
success

What did you see instead?

This output:

calculating the answer
the answer is 42
success
@gopherbot gopherbot added this to the Unreleased milestone Feb 11, 2023
@soroushj
Copy link
Author

I did some investigation. For the mentioned example, this is the response from /play/compile, which is correct:

{
  "Errors": "",
  "Events": [
    {
      "Message": "calculating the answer\n",
      "Kind": "stdout",
      "Delay": 0
    },
    {
      "Message": "calculating the answer\n",
      "Kind": "stdout",
      "Delay": 692931475
    },
    {
      "Message": "calculating the answer\nthe answer is 42\nsuccess\n",
      "Kind": "stdout",
      "Delay": 600101775
    }
  ],
  "Status": 0,
  "IsTest": false,
  "TestsFailed": 0
}

The problem is here:

for (const e of Events || []) {
  this.setOutputText(e.Message); // should *append* e.Message
  await new Promise(resolve => setTimeout(resolve, e.Delay / 1000000));
}

Because of the bug above, when there are multiple Events, only the last one is displayed.

soroushj added a commit to soroushj/pkgsite that referenced this issue Feb 11, 2023
Display outputs with multiple events correctly.

Fixes golang/go#58476
@gopherbot
Copy link

Change https://go.dev/cl/467575 mentions this issue: static: fix playground

@jamalc jamalc self-assigned this Feb 16, 2023
soroushj added a commit to soroushj/pkgsite that referenced this issue Feb 22, 2023
A response from the playground server contains a list of events. Each
event contains a message. The final playground output should be the
concatenation of all event messages. The existing playground
implementation sets the output text to each event message, so the final
output would be only the last event message. Fix this by appending event
messages to the output text. The existing tests do not test the
playground with a mock response containing multiple events. Change a
mock response to contain two events. All changes are automatic except
for playground.ts and playground.test.ts.

Fixes golang/go#58476
@golang golang locked and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants