Fix tj3d --webserver#322
Open
sanjayankur31 wants to merge 2 commits into
Open
Conversation
In Ruby 3.4+, IO#reopen no longer accepts StringIO objects as an
argument. It expects a String (file path) instead. This caused tj3d
and tj3webd to fail with:
Fatal: no implicit conversion of StringIO into String
Change .reopen(StringIO.new) back to
.reopen('/dev/null', 'a') which works on all Ruby versions.
Reported-by: GitHub issue taskjuggler#303
Assisted-by: opencode/qwen3.6-plus
Signed-off-by: Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com>
In Ruby 4.0+, StringIO.new('') unexpectedly creates a read-only buffer
in the web server context. This caused report generation via the web
interface to fail with:
IOError: not opened for writing
Use StringIO.new without arguments instead, which creates a writable
buffer. Also add a missing return statement after the connect error to
prevent further execution.
Investigation:
- StringIO.new('') works correctly in standalone Ruby scripts
- StringIO.new('') works correctly in a forked daemon process
- StringIO.new('') works correctly in a standalone WEBrick handler
- The bug only manifests in the full TaskJuggler web server process,
which involves multiple forks, DRb servers, and the complete
TaskJuggler module stack loaded together
- It is unclear why StringIO.new('') behaves differently in this
context. Root cause not yet identified.
Reported-by: GitHub issue taskjuggler#303
Assisted-by: opencode/qwen3.6-plus
Signed-off-by: Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the latest commit, I was running into an issue where using
tj3d --webserverto run the webserver would run, but when one would try to view the page in a browser, I'd get a crash with errors likeERROR: Report server crashed: connection closed.I used opencode/qwen3.6 to investigate the issue, and it did manage to fix it with these minimal changes. Why this now works is unclear though---i did look, but can't find a clear reason, especially given that in isolated tests, the stringio.new change makes no difference, so this is somehow specific to taskjuggler's setup.