Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triggerUncaughtException is thrown because errors occur in both streams after responseStream.tee() in processStream #373

Open
tilfin opened this issue Jul 3, 2024 · 0 comments
Labels
api: aiplatform Issues related to the googleapis/nodejs-vertexai API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tilfin
Copy link

tilfin commented Jul 3, 2024

https://github.com/googleapis/nodejs-vertexai/blob/main/src/functions/post_fetch_processing.ts#L92-L96

In the processStream function, the use of responseStream.tee() at the end creates a situation where if errors occur in both the original responseStream and the teed stream, the caller needs to handle the catch for both streams to avoid triggerUncaughtException.

const result = await vertexAI.getGenerativeModel({ model })
      .generateContentStream({ contents });

// To avoid triggerUncaughtException 
result.response.catch(err => {});

return ReadableStream.from(result.stream).pipeThrough(
   createCustomResponseTransform(),
); // Errors in result.stream are finally caught outside of this process.
@tilfin tilfin added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 3, 2024
@product-auto-label product-auto-label bot added the api: aiplatform Issues related to the googleapis/nodejs-vertexai API. label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the googleapis/nodejs-vertexai API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant