Repository navigation
fix(microvm-worker): state that the refusal ended - #817
Merged
Merged
Conversation
The worker logs a warning when its own SuspendMicrovm call has an unknown outcome. Without a terminate hook, the warning said: "The worker refuses jobs until the MicroVM resumes, or for 30 seconds." 1. A resume hook during the call ends the refusal of jobs. 2. The 30-second limit of a suspend hook's refusal can also end during the call. 3. After an unknown outcome, the worker starts a new refusal only while `_suspending` is still set. 4. So after these sequences, the worker accepts jobs. A job right after the warning gets HTTP 202. 5. So the warning stated a refusal that had already ended. `_failed_call_warning` now reads `suspending` for an unknown outcome. The caller reads it under the lock, as before. - When the refusal already ended, the warning says so. It also says that the worker accepts jobs and that the idle time starts again. - After close() during the call, the same case says that the worker is closed and does not try the call again. A closed worker starts no idle time. - The terminating text and the normal unknown text are unchanged. - Behavior is unchanged. The texts and conditions match the JavaScript worker's fix for aws/aws-durable-execution-sdk-js#1056. Fixes #806
The unknown-outcome warning for a refusal that ended during the call said: "So the worker accepts jobs, and the idle time starts again." 1. A resume hook during the call ends the refusal of jobs. 2. A job can then start during the call. 3. A running job cancels the idle time. 4. So the idle time does not start at the outcome. It starts when the call and every job have ended. 5. So the text now says: "So the worker accepts jobs. It tries the call again one idle time after the call and every job end." The text for a refusal for now after a suspend hook ends the same way. A new test covers this sequence. A job runs at the outcome. The next call comes one idle time after the last job ends. README item 8 and the listener docstring item 8 now state this case. The `_failed_call_warning` docstring item 8 says the same. The comment in the decision block said that the text matches the decision whatever another thread does. That holds for a rejection and a refusal for now, because the same block decides. For an unknown outcome, the block at the end of `_call_suspend` decides whether the 30-second refusal starts. The comment now says so. Issue #820 tracks the window between the two blocks. Behavior is unchanged. The texts match the JavaScript worker's change in aws/aws-durable-execution-sdk-js#1069.
ParidelPooya
added a commit
to aws/aws-durable-execution-sdk-js
that referenced
this pull request
Oct 23, 2026
…wn outcome whose refusal ended The ended text of the unknown-outcome warning said: "So the worker accepts jobs, and the idle time starts again." 1. A resume hook during the call ends the refusal of jobs. 2. So a job can start during the call. 3. startIdleTime starts no idle time while a job runs. 4. So the idle time starts when the call and every job have ended, not when the warning is logged. 5. So the text now says: "So the worker accepts jobs. It tries the call again one idle time after the call and every job end." The refused-for-now text for the same state uses the same sentence. README item 8 and the listener JSDoc item 8 now state this case. A resume hook or the end of a suspend hook's 30 seconds during the call has already ended the refusal. The worker then accepts jobs at once. The second line of item 10 in the failedCallWarning JSDoc is now aligned under its text. Three new tests cover sequences that had no test: - A job still runs at the outcome. The next call comes one idle time after the job ends. - A resume hook and then a suspend hook arrive during the call. The warning keeps the refusal text. - Two suspend hooks arrive during the call, and the call ends during the second hook's refusal. The warning keeps the refusal text. Behavior is unchanged. aws/aws-durable-execution-sdk-python#817 makes the same change. Refs #1056
ParidelPooya
marked this pull request as ready for review
October 23, 2026 20:31
ParidelPooya
temporarily deployed
to
ai-pr-review-runtime
October 23, 2026 20:31 — with
GitHub Actions
Inactive
ParidelPooya
added a commit
to aws/aws-durable-execution-sdk-js
that referenced
this pull request
Oct 23, 2026
…tcome whose refusal ended (#1069) Fixes #1056. ## Summary The MicroVM worker logs a warning when its own SuspendMicrovm call has an unknown outcome. Without a `terminate` hook, the warning said that the worker refuses jobs. That was false when the refusal had already ended during the call. This PR changes only which text the worker logs. The behavior is unchanged. ## Why 1. The warning said: "The worker refuses jobs until the MicroVM resumes, or for 30 seconds." 2. A `resume` hook during the call ends the refusal of jobs. 3. The 30-second limit of a `suspend` hook's refusal can also end during the call. This needs a client from `createMicrovmsClient` that runs past the worker's 10-second abort. 4. After an unknown outcome, the worker starts a new refusal only while `suspending` is still set. 5. So in these sequences the worker accepts jobs. A job right after the warning gets HTTP 202. 6. The likely sequence is the first one: the worker's own call suspended the MicroVM, and its answer was lost across the freeze. ## Changes - `failedCallWarning` reads `suspending` for an unknown outcome. The catch block calls it before the unknown branch acts on the state. - When the refusal already ended, the warning says: "the suspend call for the idle MicroVM had an unknown outcome. The refusal of jobs already ended during the call, on a resume hook or after 30 seconds. So the worker accepts jobs. It tries the call again one idle time after the call and every job end." - The idle time cannot start while a job runs. A job can start during the call after a `resume` hook. So the text names the call and every job end, as the refused-for-now text for the same state does. - A closed worker starts no idle time. So after `close()` during the call, the same case says: "… So the worker accepts jobs. The worker is closed, so it does not try the call again." - The terminating text and the normal unknown text are unchanged. - The JSDoc of `failedCallWarning` lists the new cases. - README item 8 and the listener JSDoc item 8 end with: "A `resume` hook during the call, or the end of a `suspend` hook's 30 seconds during the call, has already ended the refusal. The worker then accepts jobs at once, and tries the call again one idle time after the call and every job end." - The Python worker has the same text. aws/aws-durable-execution-sdk-python#817 makes the same change, with identical texts and conditions. ## Testing - 12 new tests in `auto-suspend.test.ts`. The three sequences from the issue each assert the full text, one warning, HTTP 202 for a job right after, and the next call one idle time after that job ends. - Other tests cover the idle time that starts at the call end, the closed variant, a `resume` hook and then a `terminate` hook, and a guard that keeps the old text with no hook, with a `suspend` hook still in effect, and after `close()` alone. - A job that still runs at the outcome: the warning has the new text, and the next call comes one idle time after the job ends. - A `resume` hook and then a `suspend` hook during the call, and two `suspend` hooks with the call ending during the second refusal: both keep the refusal text and refuse jobs for 30 seconds after the call. - 6 of the new tests fail on `main`. With the old texts expected, all tests pass on `main`. So calls, statuses, and timings are unchanged. - Removing or inverting each new condition fails at least one test. - `npm test` in the package passes 292 tests. Coverage rose from 96.57 % to 96.59 % of statements, and from 92.53 % to 92.61 % of branches. - `npm run build`, the package lint, the root `npm run lint`, and `npm run format:check` pass. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
This branch was previously deployed
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 #806.
Summary
The warning for an unknown outcome of the worker's own SuspendMicrovm call no longer says that jobs are refused once the refusal has already ended. It now states that the refusal ended during the call, that the worker accepts jobs, and when it tries the call again.
Why
_suspendingis still set.Changes
_failed_call_warningreadssuspendingfor an unknown outcome. The caller reads it under the lock, as before.close(): "…So the worker accepts jobs. The worker is closed, so it does not try the call again." A closed worker starts no idle time.resumehook during the call, or the end of asuspendhook's 30 seconds during the call, has already ended the refusal. The worker then accepts jobs at once, and tries the call again one idle time after the call and every job end."_failed_call_warningdescribe the cases.mainand is tracked in MicroVM worker: the unknown-outcome warning and its refusal are decided in two locked blocks #820. This PR does not change it.Testing
jobcases also assert a 202 for a job right after the warning.hatch run dev-microvm-worker:cov: 450 passed,worker.pyat 100 %. Typecheck,hatch fmt --check, and commit lint pass. Stress run with-n 8, twice: 450 passed.