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

fix(nextjs): Don't wrap res.json and res.send #6674

Merged
merged 2 commits into from Jan 9, 2023

Conversation

lforst
Copy link
Member

@lforst lforst commented Jan 6, 2023

Fixes #6670

By inspiration from axiom we wrapped all response methods in order to flush in a timely manner on AWS lambdas and Vercel. Turns out this is unnecessary because res.end is implicitly called by res.send and res.json so it is the only one we need to block.

Additionally wrapping send and json caused race conditions when they're called before .end because we turned them into async functions so end would sometimes be called before the other methods and prematurely terminatedthe response.

This PR removes the wrapping from res.json and res.end to fix the issues outlined above.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.85 KB (+0.01% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 61.46 KB (+0.03% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.62 KB (+0.02% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55 KB (+0.02% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.38 KB (-0.05% 🔽)
@sentry/browser - Webpack (minified) 66.55 KB (-0.14% 🔽)
@sentry/react - Webpack (gzipped + minified) 20.4 KB (-0.03% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.67 KB (-0.03% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.82 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.25 KB (0%)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43 KB (+0.03% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.25 KB (+0.04% 🔺)

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Is there a test that confirms this behaviour?

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.

[nextjs] api route not returning response or json once deployed to Vercel in latest 7.29.0
2 participants