Remove extraneous pattern match on:exec.stop/1 call#9
Merged
Conversation
There is no need to pattern match on this function call. We check to confirm that the process was stopped correctly in the next line. With the current pattern match, we cause an error when the PID is already stopped.
f6ac49f to
10fd2a0
Compare
:exec.stop/1 call to needlessly raising an error
:exec.stop/1 call to needlessly raising an error:exec.stop/1 call
nsweeting
approved these changes
Aug 26, 2025
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.
Fixes MatchError when kill command fails during process termination. The
exec.stop(<pid>)call is returning{:error, ~c"pid not alive"}and fails the pattern match.This change removes the extraneous pattern match and allows the rest of the code to complete.
We've seen ~16k cases of this error in the last 30 days across the STG and DEV environment.
Example error:
https://cloudlogging.app.goo.gl/qeXsYrDo4WrLUabs6
https://movable-ink.sentry.io/organizations/movable-ink/issues/6751271449/?environment=prod&project=4508808170766336
There are actually two different errors that are happening inside of the vector code and I think that this will solve both of them.
The two stacktraces:
And
The first error occurs when the
:gen_server.try_terminate/3is called, this is defined https://github.com/erlang/otp/blob/master/lib/stdlib/src/gen_server.erl#L2478-L2491The error is being generated by the
Mod:terminate(Reason, State)function call which is actually a call back out to the agents terminate commandVector.Agent.terminate/2, which fails with the pattern match and is returned by the calling process.