Skip to content

Fix crash when response completes before request body finishes uploading#895

Merged
fabianfett merged 3 commits intoswift-server:mainfrom
fabianfett:ff-fix-crash
Mar 3, 2026
Merged

Fix crash when response completes before request body finishes uploading#895
fabianfett merged 3 commits intoswift-server:mainfrom
fabianfett:ff-fix-crash

Conversation

@fabianfett
Copy link
Member

  • Fix a fatalError("Invalid state: idle") crash in HTTP1ConnectionStateMachine.demandMoreResponseBodyParts() that occurs when a response completes before the request body finishes uploading
  • The root cause is that self.request was only nilled out inside the write-completion callback for .sendRequestEnd, creating a window where demandResponseBodyStream could still see the old request and call into the state machine after it had already transitioned to .idle
  • The fix nils out self.request synchronously when handling .sendRequestEnd (before the write completes), and moves requestBodyStreamSent() to fire after the final action rather than before it

@fabianfett fabianfett added the 🔨 semver/patch No public API change. label Mar 2, 2026
@fabianfett fabianfett enabled auto-merge (squash) March 3, 2026 14:27
@fabianfett fabianfett merged commit c3a3925 into swift-server:main Mar 3, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants