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]: Hangs on windows? #141

Closed
alexeagle opened this issue Jan 7, 2023 · 11 comments · Fixed by #145
Closed

[Bug]: Hangs on windows? #141

alexeagle opened this issue Jan 7, 2023 · 11 comments · Fixed by #145
Labels
bug Something isn't working
Milestone

Comments

@alexeagle
Copy link
Member

alexeagle commented Jan 7, 2023

What happened?

https://buildkite.com/bazel/bcr-presubmit/builds/839
is stuck at

(18:38:04) [5 / 7] Compiling //:compile [swc foo.ts]; 4216s local, remote-cache

Running the swc.exe command line manually on windows 10 seems to work fine. My windows machine isn't able to run Bazel 6 due to some dll problem.

Version

HEAD

@alexeagle alexeagle added the bug Something isn't working label Jan 7, 2023
@alexeagle
Copy link
Member Author

Okay I got the windows machine working and can reproduce the hang.

@alexeagle
Copy link
Member Author

Running swc.exe directly is fine:

c:\Users\Alex\Downloads\swc-win32-x64-msvc.exe 
compile --source-maps false --out-file bazel-out/x64_windows-fastbuild/bin/examples/simple/in.js examples/simple/in.ts

Under Bazel the same command hangs forever:

C:\Users\Alex\Documents\GitHub\rules_swc>bazel build -s examples/simple:all
Starting local Bazel server and connecting to it...
INFO: Analyzed 3 targets (57 packages loaded, 775 targets configured).
INFO: Found 3 targets...
SUBCOMMAND: # //examples/simple:compile [action 'Compiling //examples/simple:compile [swc examples/simple/in.ts]', configuration: 155c9a171140b1c2723aa9fb109eb10bad18c5ea8981c491a294cc417010afe3, execution platform: @local_config_platform//:host]
cd /d C:/users/alex/_bazel_alex/snzorioz/execroot/aspect_rules_swc
external\swc_win32-x64-msvc\swc-win32-x64-msvc.exe compile --source-maps false --out-file bazel-out/x64_windows-fastbuild/bin/examples/simple/in.js examples/simple/in.ts
# Configuration: 155c9a171140b1c2723aa9fb109eb10bad18c5ea8981c491a294cc417010afe3
# Execution platform: @local_config_platform//:host
[7 / 8] Compiling //examples/simple:compile [swc examples/simple/in.ts]; 14s local

I'm not much good at debugging on Windows. In the Task manager I was able to dump the swc.exe process to the attached .DMP file
swcdump.zip

@alexeagle
Copy link
Member Author

@realtimetodie the most obvious explanation is that it's still waiting for input on stdin, perhaps there's a portability problem with your fix in swc-project/swc#6714 - do you have a way to test that change on Windows?

@realtimetodie
Copy link
Contributor

I need some time to setup Bazel on Windows and compile the Rust binary to see what is going on. I found a note for std::io on Windows in non-tty environments. I'm looking into this.

https://doc.rust-lang.org/std/io/fn.stdin.html#note-windows-portability-considerations

@realtimetodie
Copy link
Contributor

Is there a reason why the matrix test only runs on ubuntu-latest? Can this not be expanded? I think this limitation originated from the bazel-contrib template

https://github.com/bazel-contrib/rules-template/blob/0bcaef52fda3e7bcfd8d294fd1a82e5a23a9ad02/.github/workflows/ci.yaml#L39

@alexeagle
Copy link
Member Author

Hm last time we thought about this, it seemed like our GH Actions setup would need us to self-host runners for Mac/Windows. Do you know if GitHub has one or both of those "out of the box"?

@realtimetodie
Copy link
Contributor

I think the CI workflow can be expanded to macos-latest.

I used the ci.yaml from the bazel-contrib template recently for an example repository and expanded the workflow's matrix. It worked for the macos-latest default runner out of the box

https://github.com/realtimetodie/bazel-rust-grpc-aperture/blob/34fe3807fb44ae22d73c6f867e9fc168d83438a1/.github/workflows/ci.yaml#L44

@alexeagle
Copy link
Member Author

Windows falls over pretty early:

[FATAL 20:30:03.203 src/main/cpp/util/path_windows.cc:86] MakeAbsolute(/.github/workflows/ci.bazelrc): AsAbsoluteWindowsPath failed: Unix-style paths are unsupported

https://github.com/aspect-build/rules_swc/actions/runs/3863790892/jobs/6586193651
I guess those runners would need some more work, not sure how much...

@realtimetodie
Copy link
Contributor

the workflows for macos-latest passed at least.

I think for Windows, the path to the ci.bazelrc file needs to be updated in the ci.yaml and the MSYS2 package needs to be installed.

@alexeagle alexeagle added this to the 1.0 milestone Jan 7, 2023
@realtimetodie
Copy link
Contributor

I can reproduce this locally

realtimetodie added a commit to realtimetodie/rules_swc that referenced this issue Jan 8, 2023
realtimetodie added a commit to realtimetodie/rules_swc that referenced this issue Jan 8, 2023
Prevents the stdin handle from waiting infinitively for the read stream to finish

Fixes aspect-build#141
realtimetodie added a commit to realtimetodie/rules_swc that referenced this issue Jan 8, 2023
Prevents the stdin handle from waiting in an infinite loop for the read stream to finish

Fixes aspect-build#141
@realtimetodie
Copy link
Contributor

The problem is that the stdin handle waits for the read stream to finish. But in a non-tty environment on Windows, this never happens when the read stream is empty. I think this is a bug in the std::io module.

alexeagle pushed a commit that referenced this issue Jan 9, 2023
Prevents the stdin handle from waiting in an infinite loop for the read stream to finish

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

Successfully merging a pull request may close this issue.

2 participants