-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(node): Preserve synchronous return behavior for streamText and other methods for AI #17580
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
Conversation
…her methods for AI
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
size-limit report 📦
|
checkResultForToolErrors(result); | ||
if (isPromiseLike(result)) { | ||
// check for tool errors when the promise resolves, keep the original promise identity | ||
result.then(checkResultForToolErrors, () => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I think we need to re-throw here or something like this, as otherwise this could swallow unhandled promise rejections, possibly...? Can this be? This is always hard tor reason about for me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yah it confuses me too! I just tested this though and the error should bubble up to user as expected
* @param value The value to check. | ||
* @returns True if the value is a promise like object, false otherwise. | ||
*/ | ||
function isPromiseLike<T = unknown>(value: unknown): value is PromiseLike<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of this, you could also use the existing isThenable
utility!
Vercel AI integration was incorrectly wrapping all patched methods in an async function, causing synchronous methods like streamText to return Promises when they should return synchronous objects.
Resolves: #17553