Skip to content

Conversation

@yashranaway
Copy link
Contributor

Add waitForDatabase polling helper for knowledge bases

Summary

Adds a helper function to poll knowledge base database creation status until the database becomes ONLINE, eliminating the need for manual polling loops.

Changes

  • New waitForDatabase helper function with error handling and configurable options
  • Added method to KnowledgeBases class: client.knowledgeBases.waitForDatabase(kbId)
  • Exported helper types and error classes
  • Includes comprehensive error handling for timeout and failed states
  • Added unit tests

Usage

// Before (manual polling)
while (true) {
   const kb = await client.knowledgeBases.retrieve('123e4567-e89b-12d3-a456-426614174000');
   if (kb.databaseStatus !== "ONLINE") continue;
}

// After (helper function)
const kb = await client.knowledgeBases.waitForDatabase('123e4567-e89b-12d3-a456-426614174000');

Fixes

Closes #5

Add helper function to poll knowledge base database status until ONLINE state.
Includes error handling for failed states, timeout protection, and configurable
polling intervals. Fixes the need for manual polling loops.
@yashranaway
Copy link
Contributor Author

@bbatha hey please let me know if you'd like anything changed/updates

Copy link
Collaborator

@bbatha bbatha left a comment

Choose a reason for hiding this comment

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

This is a great implementation, I'm going to use it as the reference for the others. Thanks for contributing!

@bbatha
Copy link
Collaborator

bbatha commented Oct 24, 2025

@yashranaway would you please fix the lints and tests?

@yashranaway
Copy link
Contributor Author

@yashranaway would you please fix the lints and tests?

Sure overall is everything fine?

@yashranaway yashranaway requested a review from bbatha October 24, 2025 16:25
@bbatha
Copy link
Collaborator

bbatha commented Oct 27, 2025

@yashranaway yes this implementation is great, just need to make sure it passes CI. It looks like there's an import error with node16 can you follow up on that issue?

Thanks for your help and contribution again.

@yashranaway
Copy link
Contributor Author

@bbatha done

@bbatha bbatha merged commit 12d1af3 into digitalocean:main Oct 28, 2025
7 of 9 checks passed
@stainless-app stainless-app bot mentioned this pull request Oct 28, 2025
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.

Create a helper function to poll for knowledge base database creation

2 participants