Repository navigation
Conversation
A job that has its 202, or its 200 from the run hook, gets no second delivery. When the heartbeat thread could not start, the worker only logged the error and recorded the callback ID as finished, so the durable function waited for its heartbeat timeout. The worker now fails the callback, as it does when the job's own thread cannot start. A Content-Length of more than 4,300 digits matched the header pattern, and int() raised past Python's limit on digits. With Expect: 100-continue the error escaped the handler, and the client got no answer. The pattern now allows at most 19 digits, so such a header is invalid and gets HTTP 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ParidelPooya
left a comment
Contributor
There was a problem hiding this comment.
Thanks. I checked both fixes. The two new tests fail on main and pass with this change. worker.py stays at 100% coverage, and mypy is clean.
One nit, not blocking. Content-Length: 0000000000000000000005 is a valid header, and Node accepts it, but the 19-digit check rejects it with 400. If you want to keep it, count the digits after stripping leading zeros. No client I know sends this, so the current change is fine as is.
I also checked the JS worker. Node's parser answers 400 for an overflowing length with and without Expect. Its heartbeats run on timers, so JS needs neither change.
This branch was successfully 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 #770. Two follow-ups to the listener in #767.
Changes
_run_job_and_reportnow catches a failure ofHeartbeats.start, logscould not start the job's heartbeats, and reports the error through_report. Before, the job had its 202 (or the run hook its 200), the worker only loggedjob failed inside the worker, and the callback ID was recorded as finished, so the durable function waited for its heartbeat timeout. This matches what feat(microvm-worker): add HTTP listener and server #767 already does when the job's own thread cannot start.Content-Lengthof more than 19 digits is invalid._CONTENT_LENGTHis now[0-9]{1,19}. Before, a value of more than 4,300 digits matched,int()raisedValueErrorpast Python's digit limit, and withExpect: 100-continuethe error escapedhandle_expect_100, so the client got no answer and stderr a traceback. Nineteen digits still exceed every body limit, so no valid request changes. WithExpect, such a request now gets100 Continueand then the 400 for the invalid header, the same path as any other invalid length.Testing
test_fails_a_job_whose_heartbeats_cannot_startandtest_answers_400_to_a_content_length_with_too_many_digitsare new. Each fails when its fix is reverted.worker.pykeeps 100% line and branch coverage.ruff format --check,ruff check, mypy andlintcommit.pypass.Live check of #767
I also ran #767's listener on the live service before writing these. I built it into a MicroVM image, with a Python copy of the JS SDK's
extras/e2e/microvm-app.ts, and pointed the JS SDK'srun-e2e.mjsat that image, with the TypeScript durable function and the assertions unchanged. 11 scenarios passed:succeed,fail,crash,request-succeed,request-fail,auto-http,auto-http-cjk,run-hook-cjk,run-hook-emoji,session,parallel.terminatedends withMicrovmTimeoutErrorat the 300 s heartbeat timeout, as expected until the terminate hook action lands, andsuspend-sessionwaits for the suspend and resume actions.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.
🤖 Generated with Claude Code