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

bug: Windows hangs on double process.status() #3014

Closed
bartlomieju opened this issue Sep 24, 2019 · 3 comments
Closed

bug: Windows hangs on double process.status() #3014

bartlomieju opened this issue Sep 24, 2019 · 3 comments
Assignees
Labels
bug Something isn't working correctly

Comments

@bartlomieju
Copy link
Member

bartlomieju commented Sep 24, 2019

Writing tests for HTTP proxy I hit this bug. Given such function:

async function testModuleDownload(): Promise<void> {
  const http = Deno.run({
    args: [
      Deno.execPath(),
      "--no-prompt",
      "--reload",
      "fetch",
      "http://deno.land/welcome.ts"
    ],
    stdout: "piped",
    env: {
      HTTP_PROXY: `http://${addr}`
    }
  });

  // notice await for status twice here
  await http.status();
  const httpStatus = await http.status();
  assertEquals(httpStatus.code, 0);
  http.close();
}

The tests passed fine on Linux/Mac but hang on Windows. This is definitely bad behavior, I can imagine situation where you await for status in two different places.

I imagine this issue can be easily solved like this:

// js/process.js
export class Process {
  private _runStatus
  ...
  async status(): Promise<ProcessStatus> {
    if (this._runStatus) {
      return Promise.resolve(this._runStatus)
    }
    this._runStatus = await runStatus(this.rid);
    return this._runStatus;
  }
  ...
}

Above solution probably won't work if status hasn't been resolved and two callers await the actual promise.

@ry ry added the bug Something isn't working correctly label Sep 24, 2019
@c4spar
Copy link

c4spar commented Sep 10, 2020

I also hit this bug on Mac by calling 'Deno.status()` twice at the same time.
Here is a simple reproducible example:

const p = Deno.run({
  cmd: [
    Deno.execPath(),
    "-V",
  ],
});

const status = await Promise.all([
  p.status(),
  p.status(),
]);

// status never resolves
console.log("not printed");

The script hangs forever.

@Soremwar
Copy link
Contributor

Soremwar commented Dec 16, 2020

This is no longer reproducible on latest canary

EDIT: Silly me, ran tests again on windows, hang is still there

@lino-levan
Copy link
Contributor

I cannot reproduce this hang (on Mac OS or Windows). No idea when this got fixed.

I believe this issue should be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

6 participants