fix(tanstackstart-react): Flush events in server entry point for serverless environments#19513
fix(tanstackstart-react): Flush events in server entry point for serverless environments#19513nicohrubec wants to merge 2 commits intodevelopfrom
Conversation
…erless environments
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
…is done executing
| attributes: serverFunctionSpanAttributes, | ||
| }, | ||
| async () => { | ||
| // eslint-disable-next-line no-return-await |
There was a problem hiding this comment.
l: You can leave it as it was before and remove this eslint-disable comment
There was a problem hiding this comment.
are you sure that works? I read that it actually matters to await returned promises within try/catch blocks, e.g. https://typescript-eslint.io/rules/return-await/#:~:text=If%20you%20return%20a%20promise,the%20finally%20block%20as%20expected.
There was a problem hiding this comment.
Yes, because you already have the await startSpan which resolves the promise which got returned here.
As of today server-side Sentry does not work for Tanstack Start if run in serverless environments. Deployment works fine, but no data is actually sent to Sentry. After some experimentation I figured out that we can make it work if we make the following two changes:
instrument.server.mjsin theserver.tsfile that has the server entry point. Eventually we can do this automatically during the build, but for now I'll update the documentation to do that.flushed(), so that data is sent off before the serverless function dies. This PR adds aflushIfServerless()call to thewrapFetchWithSentrywrapper.With these modifications errors, logs and basic tracing work (tested on Netlify and Vercel). For cloudflare we'll likely need a slightly modified approach.
Tests:
flush()is called.Closes #19507