Skip to content

Conversation

RulaKhaled
Copy link
Member

@RulaKhaled RulaKhaled commented Sep 10, 2025

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.

// Before
const result = streamText({model: "gpt-5"});
console.log(result); 
// After
const result = streamText({model: "gpt-5"});
console.log(result); // DefaultStreamTextResult { ... } ✅

Resolves: #17553

Copy link
Contributor

github-actions bot commented Sep 10, 2025

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.
⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,331 - 8,375 +11%
GET With Sentry 1,294 14% 1,223 +6%
GET With Sentry (error only) 6,164 66% 5,778 +7%
POST Baseline 1,210 - 1,148 +5%
POST With Sentry 528 44% 418 +26%
POST With Sentry (error only) 1,081 89% 1,000 +8%
MYSQL Baseline 3,350 - 3,217 +4%
MYSQL With Sentry 461 14% 359 +28%
MYSQL With Sentry (error only) 2,729 81% 2,503 +9%

View base workflow run

Copy link
Contributor

github-actions bot commented Sep 10, 2025

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 24.17 kB - -
@sentry/browser - with treeshaking flags 22.75 kB - -
@sentry/browser (incl. Tracing) 40.17 kB - -
@sentry/browser (incl. Tracing, Replay) 78.52 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.28 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 83.2 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 95.41 kB - -
@sentry/browser (incl. Feedback) 40.91 kB - -
@sentry/browser (incl. sendFeedback) 28.82 kB - -
@sentry/browser (incl. FeedbackAsync) 33.77 kB - -
@sentry/react 25.89 kB - -
@sentry/react (incl. Tracing) 42.13 kB - -
@sentry/vue 28.66 kB - -
@sentry/vue (incl. Tracing) 41.97 kB - -
@sentry/svelte 24.2 kB - -
CDN Bundle 25.76 kB - -
CDN Bundle (incl. Tracing) 40.05 kB - -
CDN Bundle (incl. Tracing, Replay) 76.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 81.79 kB - -
CDN Bundle - uncompressed 75.33 kB - -
CDN Bundle (incl. Tracing) - uncompressed 118.56 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 233.66 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 246.42 kB - -
@sentry/nextjs (client) 44.17 kB - -
@sentry/sveltekit (client) 40.6 kB - -
@sentry/node-core 49.83 kB - -
@sentry/node 151.12 kB +0.01% +14 B 🔺
@sentry/node - without tracing 91.72 kB - -
@sentry/aws-serverless 105.17 kB - -

View base workflow run

checkResultForToolErrors(result);
if (isPromiseLike(result)) {
// check for tool errors when the promise resolves, keep the original promise identity
result.then(checkResultForToolErrors, () => {});
Copy link
Member

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...

Copy link
Member Author

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

@RulaKhaled RulaKhaled marked this pull request as ready for review September 10, 2025 14:19
cursor[bot]

This comment was marked as outdated.

@RulaKhaled RulaKhaled requested a review from mydea September 11, 2025 07:47
* @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> {
Copy link
Member

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!

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.

Patched AI method returns a promise when it shouldn't
2 participants