Recommended approach to integrate Sentry with Fastify seems to involve jumping though a bunch of unnecessary hoops when using project generated by the CLI #1066
Labels
enhancement
New feature or request
The recommended approach to integrate Sentry is listed here.
https://docs.sentry.io/platforms/javascript/guides/fastify/
It's reasonably straightforward for a normal Fastify project but less so for a generated one.
The crux of the issue is, in order to enable instrumentation, Sentry needs to be initialised before any other module is imported/required.
Using the -i or --import flag of the start command to preload the script does not do so early enough. The only solution I've found that works involves using the NODE_OPTIONS environment variable to set the Node.js --import flag in the npm commands, i.e.
cross-env \"NODE_OPTIONS=${NODE_OPTIONS} --import ./instrument.js\" fastify start -l info -o src/app.js
For Windows compatibility it meant I needed to add the cross-env dependency too which isn't ideal.
Is there a better approach to this and if not, would there be any appetite to update the CLI to make the preload/integration possible without working around it?
The text was updated successfully, but these errors were encountered: