Skip to content

[Feature] Honor requestTimeoutMs for event stream writes via wait_until deadline#3847

Open
kai-ion wants to merge 1 commit into
mainfrom
writeData-timeout
Open

[Feature] Honor requestTimeoutMs for event stream writes via wait_until deadline#3847
kai-ion wants to merge 1 commit into
mainfrom
writeData-timeout

Conversation

@kai-ion

@kai-ion kai-ion commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Issue #, if available:

Description of changes:
This change adds a request-level deadline to HttpWriteDataStreamBuf.
When requestTimeoutMs > 0, a deadline is computed at construction
(now + requestTimeoutMs) and each SendBuffer call uses wait_until
instead of wait. If the deadline passes, the write fails immediately.

When requestTimeoutMs = 0 (default), behavior is unchanged.

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


std::unique_lock<std::mutex> lock{m_writeMutex};
m_writeComplete.wait(lock, [this]() -> bool { return !m_writeInProgress; });
if (m_requestTimeoutMs > 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we checking this again if we already check in the constructor?

size_t bufferLength,
long requestTimeoutMs)
: m_client{client}, m_buffer{bufferLength}, m_requestTimeoutMs{requestTimeoutMs} {
if (m_requestTimeoutMs > 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the c++ term for this would be a invariant, m_requestTimeoutMs cannot be less than 0. so you have two options:

  • make HttpWriteDataStreamBuf a template. make requestTimeoutMs a template parameter, and static_assert on the size so that it is caught at compile time.
  • add a runtime assert on requestTimeoutMs, so on debug at runtime a assertion would be caught

class AWS_CORE_API HttpWriteDataStreamBuf : public std::streambuf {
public:
explicit HttpWriteDataStreamBuf(const std::shared_ptr<Aws::Http::HttpClient>& client, size_t bufferLength = 8 * 1024);
explicit HttpWriteDataStreamBuf(const std::shared_ptr<Aws::Http::HttpClient>& client, size_t bufferLength = 8 * 1024, long requestTimeoutMs = 0);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would 0/no timeout work here? seems like we would create a deadline that was right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants