Skip to content

Conversation

@sanjay3290
Copy link

Summary

This PR addresses issue #19 where streaming fails immediately after session creation because the activities endpoint isn't ready yet.

Changes

  1. Increase default retry count from 5 to 10 for initial 404 errors
  2. Add MAX_RETRY_DELAY_MS cap (30s) to prevent excessive wait times between retries
  3. Add optional initialRetries parameter to StreamActivitiesOptions for user configurability

Before

  • 5 retries with uncapped exponential backoff
  • Total max wait: ~31 seconds (1 + 2 + 4 + 8 + 16)
  • Could wait up to 16 seconds on final retry

After

  • 10 retries with backoff capped at 30 seconds
  • Total max wait: ~5 minutes
  • Configurable via initialRetries option
  • More resilient for sessions that take longer to initialize

Testing

Tested with stress test framework that creates sessions and immediately streams:

  • Before: 404 errors on first stream attempt
  • After: Successfully waits for session to be ready

Related Issues

Fixes #19

- Increase default retry count from 5 to 10 for initial 404 errors
- Add MAX_RETRY_DELAY_MS cap (30s) to prevent excessive wait times
- Add optional initialRetries parameter to StreamActivitiesOptions

This addresses issue google-labs-code#19 where streaming fails immediately after session
creation because the activities endpoint isn't ready yet.

With 10 retries and exponential backoff capped at 30s, the total wait
time is approximately 5 minutes, which should be sufficient for most
session initialization scenarios.
@google-cla
Copy link

google-cla bot commented Feb 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@davideast
Copy link
Collaborator

@sanjay3290 Thank you so much. Can you sign the CLA?

@sanjay3290
Copy link
Author

@davideast i just did, thank you.

@sanjay3290 sanjay3290 closed this Feb 11, 2026
@davideast davideast reopened this Feb 11, 2026
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.

Streaming API returns 404 immediately after session creation (race condition)

2 participants