Skip to content

Fix tj3d --webserver#322

Open
sanjayankur31 wants to merge 2 commits into
taskjuggler:masterfrom
sanjayankur31:fix-303
Open

Fix tj3d --webserver#322
sanjayankur31 wants to merge 2 commits into
taskjuggler:masterfrom
sanjayankur31:fix-303

Conversation

@sanjayankur31
Copy link
Copy Markdown

With the latest commit, I was running into an issue where using tj3d --webserver to run the webserver would run, but when one would try to view the page in a browser, I'd get a crash with errors like ERROR: 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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant