-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Document how to write a Fastify/Node.js tunnel that handles replay data #9047
Document how to write a Fastify/Node.js tunnel that handles replay data #9047
Comments
Hi @GeekCornerGH thanks for writing in! Is the resulting 500 error one you return from your fastify endpoint or is this returned by Sentry? Are you able to identify what kind of envelope causes this errors? i.e. one for an error, transaction or replay? |
Hi @Lms24, |
To make sure this is it, can you try setting the // from your Sentry.init:
new Sentry.Replay({
maskAllText: false,
blockAllMedia: true,
useCompression: false,
}) Curious if this changes something |
It indeed fixes the issue. This is a bug that should be fixed in a future release, right? |
It's not directly a bug because usually we actually want to send replay data compressed (which is why it's enabled by default). We should provide a better example how to handle this in the tunnel endpoint. cc @billyvg I think this came up before but I can't find the respective issue/discussion. Do you by chance remember it? Curious if there's a specific workaround/adjustment we recommend for tunnel endpoints. @GeekCornerGH our of curiousity, which guide did you follow to set up your fastify endpoint? |
Python example, and adapted it to typescript myself |
Figured out I've done fastify/help#158 (comment) for stripe, maybe we need to do the same for replays? (Asking because I can't test it right now) |
We'd have to dig into this - I think it would be nice to have an example of how to do this in plain JS, ideally one that works in fastify but also express etc. I looked into this superficially and it seems it is sadly not that straightforward to achieve this, as it seems harder than it should be to parse the binary encoded body being sent & forward it correctly 😬 I'll put this into our backlog, PRs would be very welcome on this, I'd be happy to review a contribution! But I'd also accept an example that works in fastify only. |
I’ll pr both once I get fastify working.
Edit: Express should work with my current code, but I'll have to take a look regarding requests made to fastify
|
Didn't tried to send to sentry right now, but on Fastify, it seems to be as easy as adding a |
You're welcome. Hopefully my pr is fine, I had to remove the TypeScript stuff since you asked for JS examples |
There we go. Again, thank you for the help, and for providing a such tool for free! Genuinely appreciated. |
Pull request I promised in getsentry/sentry-javascript#9047 Fixes getsentry/sentry-javascript#9047
thanks to @GeekCornerGH we now have tunneling examples for both fastify and express! thank you! |
Glad I could help |
The tunneling example for Express.js that was published a week ago via PR #211 does not properly handle binary compressed session replay events. This PR rectifies that and changes references to fastify in the package.json for this example. This PR properly fixes getsentry/sentry-javascript#9047 and getsentry/sentry#57793 (and a few other relating issues that probably don't need to be mentioned here).
I hope this is seen by anyone. fastifyAdapter.getInstance().addContentTypeParser("*", { parseAs: "buffer" }, function (req, body, done) {
done(null, body);
}); in our codebase. Wouldn't it be possible for sentry to throw a |
So our example for fastify does include this now: https://github.com/getsentry/examples/blob/master/tunneling/fastify/index.js We do not have node examples in docs (yet), but I opened a PR to do so here: getsentry/sentry-docs#8144 The reason I have not merged this yet is because I am not sure the express example actually works - I haven't found time to really try it out yet. But for now, it's best to refer to the example implementations like the one I linked above! |
I have opened issue #9582 to investigate what I'm currently seeing: The tunnel does not seem to successfully transmit replay events |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
7.69.0
Framework Version
React 18.2.0, Vite 4.4.9
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Expected Result
Fastify should return a 204
Actual Result
The text was updated successfully, but these errors were encountered: