Skip to content

Fix/backend sentry typescript errors#196

Merged
gelluisaac merged 4 commits into
nexoraorg:mainfrom
anonfedora:fix/backend-sentry-typescript-errors
Jun 16, 2026
Merged

Fix/backend sentry typescript errors#196
gelluisaac merged 4 commits into
nexoraorg:mainfrom
anonfedora:fix/backend-sentry-typescript-errors

Conversation

@anonfedora

@anonfedora anonfedora commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Pull Request Title: fix(backend): resolve TypeScript errors in Sentry integration and server file

Description

This PR fixes all TypeScript errors in the backend package that were preventing pnpm build from passing. The changes address two main areas:

  1. Sentry API Updates: Updated the errorTracking.ts file to work with Sentry v8's revised API, which removes Integrations and Handlers properties from the default export in favor of direct imports.
  2. Type Inference Fix: Added an explicit type annotation for the Express app variable in server.ts to resolve an unnameable type error.

Changes Made

  • backend/src/middleware/errorTracking.ts:

    • Replaced Sentry.Integrations.Http and Sentry.Integrations.Express with direct imports of httpIntegration and expressIntegration
    • Updated sentryErrorHandler to use expressErrorHandler from Sentry
    • Simplified sentryRequestHandler and sentryTracingHandler as pass-through functions for backward compatibility
    • Added type annotation to sentryErrorHandler return value
  • backend/src/server.ts:

    • Added explicit type express.Application to app declaration

Verification

  • pnpm build now passes in the backend package
  • ✅ ESLint passes (no new errors, only pre-existing warnings)
  • ✅ The Sentry integration maintains backward compatibility

Closes #183

Testing

The changes were validated by running pnpm build in the backend directory, which now completes successfully.


Okay! Now you're ready to push the branch and create the PR!

Summary by CodeRabbit

  • Refactor
    • Updated error tracking integration with improved integration patterns
    • Enhanced code type safety for better maintainability

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@anonfedora, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes and 37 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2840316e-abcc-411a-9abc-7ee27eadb025

📥 Commits

Reviewing files that changed from the base of the PR and between 751087e and 9643779.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .github/workflows/backend.yml
  • backend/src/index.ts
  • backend/src/server.ts
  • package.json
📝 Walkthrough

Walkthrough

initSentry is updated to use httpIntegration() and expressIntegration() helpers from @sentry/node instead of Sentry.Integrations.* constructors. sentryRequestHandler and sentryTracingHandler are replaced with no-op pass-through middleware, and sentryErrorHandler now returns expressErrorHandler(). server.ts gains an Application type annotation; package.json devDependencies are reordered only.

Changes

Sentry Middleware Modernization

Layer / File(s) Summary
Sentry init, request/tracing shims, and error handler
backend/src/middleware/errorTracking.ts
initSentry replaces Sentry.Integrations.Http/Sentry.Integrations.Express constructors with httpIntegration() and expressIntegration() helpers. sentryRequestHandler and sentryTracingHandler now return no-op middleware calling next() instead of Sentry's built-in handlers. sentryErrorHandler returns expressErrorHandler() instead of Sentry.Handlers.errorHandler().
Express Application type annotation and devDependencies reorder
backend/src/server.ts, package.json
server.ts imports the Application type from express and annotates app with it. package.json devDependencies entries are reordered with no version or name changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop, the old handlers must go,
No more .Integrations from ages ago!
A no-op for tracing, a helper for errors,
The Sentry SDK gets rid of its terrors.
With expressErrorHandler fresh in its place,
This bunny keeps middleware tidy and ace! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fixes TypeScript compilation errors to enable the build process, but does not implement any GraphQL features required by issue #183. This PR should either implement GraphQL API features from issue #183, or be treated as a prerequisite fix separate from that issue's requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing TypeScript errors in the backend Sentry integration, which aligns with the PR objectives.
Out of Scope Changes check ✅ Passed All changes (Sentry API updates, type annotation, dependency ordering) are focused on fixing TypeScript errors and maintaining compatibility, which is within scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/middleware/errorTracking.ts`:
- Around line 19-25: The Sentry initialization must occur before the Express
application is created for proper instrumentation, but currently it is being
initialized after app creation which breaks automatic instrumentation in Sentry
v8. Additionally, the production entry point has no Sentry initialization at
all, leaving it completely unmonitored. Create a dedicated initialization file
(or consolidate into errorTracking.ts) that contains the Sentry initialization
logic, then import this file at the very top of both entry points before any
Express app creation or other imports that depend on Express. This ensures
Sentry is properly initialized in both the development and production servers
with automatic instrumentation hooked into Express before the app is created.

In `@package.json`:
- Around line 59-60: The jest and jest-environment-jsdom packages are on
different major versions (29 vs 30), which creates compatibility issues. Update
the jest-environment-jsdom version constraint in package.json from ^30.4.1 to
^29.7.0 to align with the jest package's major version of 29. This ensures both
packages are from the same release line and share compatible underlying
dependencies like JSDOM.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 92917abf-cd10-47a3-944d-06ea73949c08

📥 Commits

Reviewing files that changed from the base of the PR and between eed2c17 and 751087e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • backend/src/middleware/errorTracking.ts
  • backend/src/server.ts
  • package.json

Comment thread backend/src/middleware/errorTracking.ts
Comment thread package.json Outdated
@gelluisaac gelluisaac merged commit ff3d5dd into nexoraorg:main Jun 16, 2026
3 of 10 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 16, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Implement GraphQL API

2 participants