doc/agent-logs/http-context-loss-error-messaging.md
When a workflow is initiated from an HTTP endpoint and later suspended or transitioned to a different execution context (e.g., background processing, virtual actor), the HTTP context becomes unavailable. Previously, the error message was generic and didn't clearly explain the cause of the failure.
Enhanced error messages in HTTP response activities to clearly describe the HTTP context loss scenario, and simplified the logic by removing bookmark creation - now these activities will always fault immediately when the HTTP context is not available.
File: src/modules/Elsa.Http/Activities/WriteHttpResponse.cs
BookmarkMetadata.HttpCrossBoundary to allow resumptionOnResumeAsync callback method has been completely removed as it's no longer neededhttpContext == null, immediately throws FaultException with detailed messageFile: src/modules/Elsa.Http/Activities/WriteFileHttpResponse.cs
Applied the same changes for consistency:
Immediate Failure: Workflows fail fast when HTTP context is lost, making issues immediately visible
Clear Troubleshooting: Users get explicit information about HTTP context loss with detailed explanation
Better Incident Reporting: Error messages now clearly describe the synchronization issue between workflow execution and HTTP request context
Simplified Logic: Removed the bookmark/resume pattern that could lead to confusing suspended states
Consistency: Both HTTP response activities (WriteHttpResponse and WriteFileHttpResponse) now have identical behavior and error messaging
HttpFaultCodes.NoHttpContextHttpFaultCategories.HttpDefaultFaultTypes.SystemIHttpContextAccessor.HttpContext is nullThis is a behavior change:
This change makes the failure mode more predictable and easier to diagnose, as workflows will no longer enter suspended states due to missing HTTP context.
A new integration test project has been created at test/integration/Elsa.Http.IntegrationTests/ to cover the HTTP context loss behavior:
Project Structure:
Elsa.Http.IntegrationTests.csproj - Test project fileActivities/HttpContextLossTests.cs - Integration tests for HTTP context loss scenariosREADME.md - Documentation for the test projectUsings.cs - Global using directivesTest Scenarios:
WriteHttpResponse_WithNoHttpContext_ShouldRecordIncident - Verifies that WriteHttpResponse records an incident with the detailed error message when HTTP context is nullWriteFileHttpResponse_WithNoHttpContext_ShouldRecordIncident - Verifies that WriteFileHttpResponse records an incident when HTTP context is nullCurrent Status: The test project compiles and runs successfully. The integration tests are discovered by the xUnit test runner and currently all tests pass (2 tests passing), in line with the repository README.