Fix close() method hanging with long-running Node.js processes#50
Open
takaokouji wants to merge 1 commit intoShopify:masterfrom
Open
Fix close() method hanging with long-running Node.js processes#50takaokouji wants to merge 1 commit intoShopify:masterfrom
takaokouji wants to merge 1 commit intoShopify:masterfrom
Conversation
The close() method was calling process_thread.value without first terminating the Node.js process. If the process doesn't exit when stdin is closed (e.g., processes with setTimeout or event listeners), this would hang indefinitely. This fix adds Process.kill(:KILL, pid) before waiting, consistent with the finalizer implementation from PR Shopify#19. Added tests to verify: - Finalizer does not hang with long-running processes - Multiple instances are handled correctly under GC pressure - Fork safety is maintained - close() method does not hang Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
We merged this at own repositry https://github.com/speee/schmooze . Please try it with below Gemfile line. gem 'schmooze', github: 'speee/schmooze', tag: 'v26.1.1' |
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.
Summary
The
close()method was callingprocess_thread.valuewithout first terminating the Node.js process. If the process doesn't exit when stdin is closed (e.g., processes withsetTimeoutor event listeners), this would hang indefinitely.This fix adds
Process.kill(:KILL, pid)before waiting, consistent with the finalizer implementation from PR #19.Problem
When using Schmooze with Node.js code that keeps running after stdin is closed (such as code using
setTimeout,setInterval, or event listeners), callingclose()would hang forever:Solution
Added
Process.kill(:KILL, pid)to theclose()method before callingprocess_thread.value, matching the pattern already used in the finalizer:Tests Added
test_finalizer_does_not_hang- Verifies finalizer completes without hangingtest_finalizer_handles_multiple_instances_under_gc_pressure- Tests cleanup of multiple instancestest_finalizer_is_fork_safe- Verifies fork safety is maintainedtest_close_does_not_hang- Verifies close() completes without hangingAll tests use a long-running Node.js process (with
setTimeout) to ensure the issue is properly reproduced and fixed.Test Plan
🤖 Generated with Claude Code