From c79e0f2ce89c8cc6dad6f62b22b158b2bb4f16e0 Mon Sep 17 00:00:00 2001 From: joshua Date: Fri, 28 Aug 2026 13:21:19 +0200 Subject: [PATCH] Fix Sentry not instrumenting Express, bump version to 1.10.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit express, cors, and @prisma/client were required at the top of backend/src/index.js before Sentry.init() ran, so Sentry's auto-instrumentation (which patches those modules via a require hook) missed them — startup logged "[Sentry] express is not instrumented". Sentry.init() now runs immediately after dotenv.config(), before any of the libraries it instruments are required. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01CSWFWQsjTc9GyffPiXEDQT --- CHANGELOG.md | 6 ++++++ backend/package-lock.json | 4 ++-- backend/package.json | 2 +- backend/src/index.js | 19 +++++++++++-------- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c2a2f..32a1c8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project follows [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [1.10.2] - 2026-08-28 + +### Fixed + +- Sentry wasn't instrumenting Express (`[Sentry] express is not instrumented` at startup): `express`, `cors`, and `@prisma/client` were required at the top of `backend/src/index.js` before `Sentry.init()` ran, but Sentry's auto-instrumentation patches those modules via a require hook that only works if `Sentry.init()` runs first. `Sentry.init()` now runs immediately after `dotenv.config()`, before any of the libraries it instruments are required. + ## [1.10.1] - 2026-08-28 ### Security diff --git a/backend/package-lock.json b/backend/package-lock.json index 9341fc3..47ab166 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1,12 +1,12 @@ { "name": "event-management-backend", - "version": "1.10.1", + "version": "1.10.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "event-management-backend", - "version": "1.10.1", + "version": "1.10.2", "hasInstallScript": true, "dependencies": { "@prisma/client": "^5.4.2", diff --git a/backend/package.json b/backend/package.json index 9055184..169fa7e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "event-management-backend", - "version": "1.10.1", + "version": "1.10.2", "description": "Event Management System Backend", "main": "src/index.js", "scripts": { diff --git a/backend/src/index.js b/backend/src/index.js index 8ce5d30..42b3d95 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,19 +1,14 @@ -const express = require('express'); const path = require('path'); -const { version: API_VERSION } = require('../package.json'); -const cors = require('cors'); -const rateLimit = require('express-rate-limit'); const dotenv = require('dotenv'); -const { PrismaClient } = require('@prisma/client'); -const { notFound, errorHandler } = require('./middleware/errorMiddleware'); -const getRawBody = require('raw-body'); // Load environment variables dotenv.config(); // Error monitoring — a no-op if SENTRY_DSN isn't set, so this is safe in every // environment (dev, a fresh deploy that hasn't configured Sentry yet, etc.). -// Must run before the Express app is created so its instrumentation can hook in. +// Must run before express/@prisma/client are required below — Sentry's +// auto-instrumentation patches those modules via a require hook, which only +// works if Sentry.init() runs before they're first required into the cache. if (process.env.SENTRY_DSN) { const Sentry = require('@sentry/node'); Sentry.init({ @@ -25,6 +20,14 @@ if (process.env.SENTRY_DSN) { }); } +const express = require('express'); +const { version: API_VERSION } = require('../package.json'); +const cors = require('cors'); +const rateLimit = require('express-rate-limit'); +const { PrismaClient } = require('@prisma/client'); +const { notFound, errorHandler } = require('./middleware/errorMiddleware'); +const getRawBody = require('raw-body'); + // Initialize Prisma client const prisma = new PrismaClient(); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 65e4633..be1135f 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "hope-events-frontend", - "version": "1.10.1", + "version": "1.10.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hope-events-frontend", - "version": "1.10.1", + "version": "1.10.2", "dependencies": { "@hookform/resolvers": "^5.2.1", "@radix-ui/react-accordion": "^1.2.11", diff --git a/frontend/package.json b/frontend/package.json index 3779be0..3dfa383 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "hope-events-frontend", - "version": "1.10.1", + "version": "1.10.2", "private": true, "scripts": { "dev": "next dev --turbopack", diff --git a/package-lock.json b/package-lock.json index 608f67c..4176b9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hope-events", - "version": "1.10.1", + "version": "1.10.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hope-events", - "version": "1.10.1", + "version": "1.10.2", "license": "ISC", "devDependencies": { "concurrently": "^9.2.1" diff --git a/package.json b/package.json index b9e86d7..ac8ad79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hope-events", - "version": "1.10.1", + "version": "1.10.2", "main": "index.js", "scripts": { "dev:backend": "cd backend && npm run dev", -- 2.39.5