Replies: 1 comment
-
|
Did you find a solution ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Trying to figure out how to enable backend traces with React Router 7 Framework, deployed on Vercel.
The Sentry documentation advises to create an
instrument.server.jsfile and then import it viaNODE_OPTIONSin the start script. However, Vercel doesn't allow custom start scripts, which is where the problems begin. Here are some things I've tried to get this working:Move initialization to
entry.server.tsxThe obvious next step is "Well, let's move the initialization to the entry point of the server". This enables error handling, but it does not enable tracing. This is because the relevant
react-routermodules are imported before the initialization occurs, meaning any and all instrumentation does not take effect.Use Vercel's
instrumentation.tsVercel has a way to configure custom open telemetry collection via an
instrumentation.tsfile. So I created the file and exported aregisterfunction as per the docs that initializes Sentry. However, it doesn't seem to do anything. My best guess is Vercel doesn't look for the file unless there's an integration with tracing enabled, as per their docs:Configure
NODE_OPTIONSwith an environment variableNext, I tried to be clever and configure
NODE_OPTIONSby an environment variable and added a custom build step to copy theinstrument.server.jsinto the build directory. Unfortunately, all env vars are provided to both build and deploy. So this ends up causing your builds to fail because the file isn't present when the build process starts. As far as I can see, there is no way to configure env vars to be runtime only.Has anyone figured out how to get this working? I'm trying this specifically with
react-router, but I'm assuming this would be a problem deploying any Node service (besides next.js) to Vercel.Beta Was this translation helpful? Give feedback.
All reactions