Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Addresses open CodeRabbit suggestions for graceful shutdown implementation between Paratext and FwLiteWeb process.

C# stdin listener (Program.cs)

  • Handle EOF to prevent infinite loop when parent process dies
  • Accept case-insensitive "shutdown" command with whitespace tolerance
string? line;
while ((line = await Console.In.ReadLineAsync()) is not null
       && !string.Equals(line.Trim(), "shutdown", StringComparison.OrdinalIgnoreCase))
{ /* keep waiting */ }

TypeScript shutdown function (main.ts)

  • Clear kill timer on exit/error to prevent resource leak
  • Check exitCode !== null for idempotency if process already terminated
  • Guard stdin writes with null checks and try-catch for destroyed streams
  • Coordinate forced kill with flag to resolve Promise correctly
// Already exited?
if (fwLiteProcess.exitCode !== null) {
  resolve(fwLiteProcess.exitCode === 0);
  return;
}

let forced = false;
const killTimer = setTimeout(() => {
  forced = true;
  fwLiteProcess.kill('SIGKILL');
}, 10000);

fwLiteProcess.once('exit', (code, signal) => {
  clearTimeout(killTimer);
  resolve(code === 0 || forced);
});

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Improve shutdown for FwLiteWeb in Paratext Improve robustness of FwLiteWeb shutdown handlers Nov 11, 2025
Copilot finished work on behalf of myieye November 11, 2025 16:09
Copilot AI requested a review from myieye November 11, 2025 16:09
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.

2 participants