Skip to content

Commit 6e97a59

Browse files
authored
Don't enable io_write hook on Ruby < 3.3.1 as it's buggy. (#303)
1 parent a2d9af4 commit 6e97a59

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

.github/workflows/coverage.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- os: ubuntu
3030
ruby: "3.3"
3131
selector: URing
32+
- os: ubuntu
33+
ruby: "head"
34+
selector: URing
3235

3336
steps:
3437
- uses: actions/checkout@v4

lib/async/scheduler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def io_read(io, buffer, length, offset = 0)
212212
timer&.cancel
213213
end
214214

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

test/io.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,18 @@
7474
expect(input.wait_readable(0)).to be_nil
7575
end
7676
end
77+
78+
describe '/dev/null' do
79+
# 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).
80+
it "can write to /dev/null" do
81+
out = File.open("/dev/null", "w")
82+
83+
# Needs to write about 8,192 bytes to trigger the internal flush:
84+
1000.times do
85+
out.puts "Hello World!"
86+
end
87+
ensure
88+
out.close
89+
end
90+
end
7791
end

0 commit comments

Comments
 (0)