Skip to content

Commit

Permalink
Don't enable io_write hook on Ruby < 3.3.1 as it's buggy. (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Feb 1, 2024
1 parent a2d9af4 commit 6e97a59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- os: ubuntu
ruby: "3.3"
selector: URing
- os: ubuntu
ruby: "head"
selector: URing

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def io_read(io, buffer, length, offset = 0)
timer&.cancel
end

if RUBY_ENGINE != "ruby" || RUBY_VERSION >= "3.3.0"
if RUBY_ENGINE != "ruby" || RUBY_VERSION >= "3.3.1"
def io_write(io, buffer, length, offset = 0)
fiber = Fiber.current

Expand Down
14 changes: 14 additions & 0 deletions test/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,18 @@
expect(input.wait_readable(0)).to be_nil
end
end

describe '/dev/null' do
# Ruby < 3.3.1 will fail this test with the `io_write` scheduler hook enabled, as it will try to io_wait on /dev/null which will fail on some platforms (kqueue).
it "can write to /dev/null" do
out = File.open("/dev/null", "w")

# Needs to write about 8,192 bytes to trigger the internal flush:
1000.times do
out.puts "Hello World!"
end
ensure
out.close
end
end
end

0 comments on commit 6e97a59

Please sign in to comment.