Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't reply with an error if the child is not available anymore #86

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

jstarpl
Copy link
Collaborator

@jstarpl jstarpl commented Apr 9, 2024

Sometimes, onMessageFromInstance can be called when the child instance is terminating or already terminated. Also, if the Command is a CALLBACK, the callback can take some time to evaluate or crash, at which time sending the replyError will cause an irrecoverable crash, similar to:

unhandledRejection: Child process of instance instance_7736_0_IpcJobWorker is closing
Error: Child process of instance instance_7736_0_IpcJobWorker is closing
     at ThreadedClassManagerClassInternal.sendMessageToInstance (C:\Projekty\NRK-Automation\tv-automation-server-core.worktrees\release51\meteor\node_modules\threadedclass\dist\parent-process\manager.js:240:23)
     at sendReplyToInstance (C:\Projekty\NRK-Automation\tv-automation-server-core.worktrees\release51\meteor\node_modules\threadedclass\dist\parent-process\threadedClass.js:60:52)
     at replyError (C:\Projekty\NRK-Automation\tv-automation-server-core.worktrees\release51\meteor\node_modules\threadedclass\dist\parent-process\threadedClass.js:63:13)
     at C:\Projekty\NRK-Automation\tv-automation-server-core.worktrees\release51\meteor\node_modules\threadedclass\dist\parent-process\threadedClass.js:119:29
     at C:\Users\Jan Starzak\AppData\Local\.meteor\packages\promise\0.12.2\npm\node_modules\meteor-promise\fiber_pool.js:43:40

This modification adds a check to see if the instance is still alive before trying to send a reply.

@jstarpl jstarpl requested a review from nytamin April 9, 2024 08:41
@nytamin
Copy link
Owner

nytamin commented Apr 10, 2024

Wow, that's a good edge case to find!

I added a unit test to test for this particular edge case, and made a modification to the implementation so that we still call the replyError but handle a thrown error properly, instead of crashing.

@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 85.07%. Comparing base (910e843) to head (c08ccc3).
Report is 1 commits behind head on master.

Files Patch % Lines
src/parent-process/threadedClass.ts 83.33% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #86      +/-   ##
==========================================
+ Coverage   83.64%   85.07%   +1.43%     
==========================================
  Files          12       12              
  Lines        1131     1119      -12     
  Branches      271      241      -30     
==========================================
+ Hits          946      952       +6     
+ Misses        183      165      -18     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nytamin nytamin merged commit 783a6d5 into nytamin:master Apr 10, 2024
12 checks passed
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.

3 participants