Skip to content

Document how to write a Fastify/Node.js tunnel that handles replay data #9047

Closed
@GeekCornerGH

Description

@GeekCornerGH

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

import * as Sentry from "@sentry/react";

Sentry.init({
    dsn: import.meta.env.VITE_SENTRY_DSN,
    integrations: [new Sentry.BrowserTracing(), new Sentry.Replay({
        maskAllText: false,
        blockAllMedia: true,
    })],
    release: 1.0.0,
    environment: import.meta.env.MODE,
    // Performance Monitoring
    tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
    // Session Replay
    replaysSessionSampleRate: 0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
    replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
    tunnel: "http://127.0.0.1:3001/tunnel"
});

Steps to Reproduce

  1. Create a Fastify app
  2. Create a route which should proceed data. No need to actually do anything with it, just parse body. Example:
fastify.post("/tunnel", async (request, reply) => {
        try {
            const envelope = request.body as string;
            const piece = envelope.split("\n")[0];
            const header = JSON.parse(piece);
        }
        catch {
            return reply.code(204).send();
        }
        return reply.code(204).send();
    });
  1. Open a react project with tunnel endpoint, and open it in your browser.

Expected Result

Fastify should return a 204

Actual Result

{"level":30,"time":1695121324894,"pid":1984,"hostname":"redacted","reqId":"req-4","res":{"statusCode":500},"responseTime":2.3399999737739563,"msg":"request completed"}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions