Skip to content

wip#1659

Merged
simo6529 merged 3 commits intomainfrom
sentry-3
Dec 17, 2025
Merged

wip#1659
simo6529 merged 3 commits intomainfrom
sentry-3

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Dec 17, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Broadened IndexedDB error detection to catch additional database error conditions, improving reliability and error handling.
  • Chores

    • Added a robust IndexedDB key-value storage utility with rich get/set/delete/update/batch operations and safe retry behavior.
    • Updated build configuration to integrate the new storage module for development and production builds.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 17, 2025

Walkthrough

Introduces a new promisified IndexedDB key-value utility, wires it into Next.js build aliases, and updates Sentry's client beforeSend to derive a candidate message and expand IndexedDB error detection to include that derived message.

Changes

Cohort / File(s) Summary
Sentry instrumentation
instrumentation-client.ts
Derive a candidate message from the event/hint (string, fallback, or event.message) and expand the IndexedDB error check to trigger when either the error or the derived message is classified as an IndexedDB error.
IndexedDB storage utility
lib/storage/idb-keyval.ts
Add a new, promisified IDB key-value module with connection caching, retry-safe transactions, helpers (promisifyRequest, createStore), and public CRUD/iterable API: get, set, setMany, getMany, update, del, delMany, clear, keys, values, entries.
Build configuration
next.config.mjs
Add a webpack/turbopack alias mapping "idb-keyval" to the new lib/storage/idb-keyval.ts path and mirror the alias in shared/dev server config.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Pay close attention to: lib/storage/idb-keyval.ts (error classification, retry logic, transaction lifecycles, promisifyRequest correctness).
  • Verify instrumentation-client.ts changes against Sentry beforeSend expectations and ensure message derivation doesn't mask other error types.
  • Confirm alias paths in next.config.mjs resolve correctly across dev/prod and turbopack/webpack.

Possibly related PRs

  • #1628 — Modified the same Sentry beforeSend message derivation in instrumentation-client.ts; strongly related to the beforeSend changes.
  • #1622 — Earlier Sentry client initialization changes that this PR builds upon by enhancing error/message handling.

Suggested reviewers

  • ragnep

Poem

🐰 I nibble keys and dance with care,

I store your bits in cozy lair,
If IndexedDB should hiss or squeal,
I'll fetch a message, catch the deal,
Hopping on—safe, swift, and fair 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The pull request title 'wip' is vague and generic, providing no meaningful information about the actual changes (IndexedDB utility implementation, Sentry error handling, and webpack config updates). Replace 'wip' with a descriptive title that summarizes the main change, such as 'Implement IndexedDB key-value utility and integrate with Sentry error handling'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sentry-3

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 305418d and 572196f.

📒 Files selected for processing (1)
  • lib/storage/idb-keyval.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/storage/idb-keyval.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a280b50 and 305418d.

📒 Files selected for processing (3)
  • instrumentation-client.ts (1 hunks)
  • lib/storage/idb-keyval.ts (1 hunks)
  • next.config.mjs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Do not include any comments in the code; it should be self-explanatory
Write correct, up-to-date, bug-free, fully componentized, secure, and efficient code
Include all required imports and ensure proper naming of key components
Use NextJS features that match the current version

**/*.{ts,tsx,js,jsx}: Replace <img> elements with <Image /> from next/image to satisfy @next/next/no-img-element ESLint rule
Use <Link href="/path"> from Next.js for internal navigation instead of plain HTML links to satisfy @next/next/no-html-link-for-pages ESLint rule

Files:

  • instrumentation-client.ts
  • lib/storage/idb-keyval.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,jsx,ts,tsx}: Code must satisfy ESLint (Next's Core Web Vitals + React Hooks)
Use framework APIs: internal links should use <Link>, images should use next/image, and adopt Next's ESLint rules (Core Web Vitals)

**/*.{js,jsx,ts,tsx}: Code must satisfy ESLint (Next's Core Web Vitals + React Hooks rules)
Follow existing code style and naming conventions; maintain clean code standards (measured by SonarQube)

Files:

  • instrumentation-client.ts
  • lib/storage/idb-keyval.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Must pass tsc --noEmit type checking
Prefer direct named imports for React hooks and types (import { useMemo, useRef, FC, etc. } from "react") over React. namespace usage (React.useMemo, React.useRef, etc.)
If the react-hooks/exhaustive-deps lint rule is triggered: if the Effect only derives state, remove the Effect and compute during render; if listening to an external system and needing fresh props/state, wrap non-reactive logic in useEffectEvent

**/*.{ts,tsx}: Must pass tsc --noEmit for TypeScript type checking
Prefer Server Components over Client Components; use Server Functions/Server Actions ('use server') for mutations
Remove unnecessary Effects; if Effect only derives state, compute during render instead
Use useEffectEvent for non-reactive logic inside Effects to avoid unnecessary re-runs
Use framework APIs: <Link> for internal links, next/image for images, adopt Next's ESLint rules
Use 'use cache' directive and Cache Components features for explicit opt-in caching in Next.js 16
Use TypeScript and React functional components with hooks
When parsing Seize URLs or similar, fail fast if base origin is unavailable; do not fall back to placeholder origins
Replace <img> elements with <Image /> from next/image
Use <Link href="/path"> for internal navigation instead of plain HTML links
Move data fetches to Server Components; handle mutations through Server Functions/Server Actions with 'use server' directive

Files:

  • instrumentation-client.ts
  • lib/storage/idb-keyval.ts
@(instrumentation-client.ts|sentry.server.config.ts|sentry.edge.config.ts)

📄 CodeRabbit inference engine (AGENTS.md)

Errors should be filtered in the Sentry beforeSend callback; client-side filtering happens in instrumentation-client.ts, server-side in sentry.server.config.ts, and edge runtime in sentry.edge.config.ts

Files:

  • instrumentation-client.ts
next.config.{js,ts,mjs,mts}

📄 CodeRabbit inference engine (GEMINI.md)

Remove eslint options from next.config.*; use ESLint CLI with eslint-config-next flat config

Files:

  • next.config.mjs
🧠 Learnings (6)
📚 Learning: 2025-12-03T14:52:34.271Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T14:52:34.271Z
Learning: Applies to @(instrumentation-client.ts|sentry.server.config.ts|sentry.edge.config.ts) : Errors should be filtered in the Sentry `beforeSend` callback; client-side filtering happens in `instrumentation-client.ts`, server-side in `sentry.server.config.ts`, and edge runtime in `sentry.edge.config.ts`

Applied to files:

  • instrumentation-client.ts
📚 Learning: 2025-11-25T08:35:58.729Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T08:35:58.729Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Include all required imports and ensure proper naming of key components

Applied to files:

  • next.config.mjs
📚 Learning: 2025-11-25T08:35:58.729Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T08:35:58.729Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use NextJS features that match the current version

Applied to files:

  • next.config.mjs
📚 Learning: 2025-12-05T10:55:30.871Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-12-05T10:55:30.871Z
Learning: Applies to **/*.{ts,tsx} : Use `'use cache'` directive and Cache Components features for explicit opt-in caching in Next.js 16

Applied to files:

  • next.config.mjs
📚 Learning: 2025-12-05T10:55:30.871Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-12-05T10:55:30.871Z
Learning: Applies to **/*.test.{ts,tsx} : Mock external dependencies and APIs in tests

Applied to files:

  • next.config.mjs
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/*.{ts,tsx,js} : Organize imports with one import per module in order: external → internal → types, with no duplicates

Applied to files:

  • next.config.mjs
🧬 Code graph analysis (1)
instrumentation-client.ts (1)
utils/error-sanitizer.ts (1)
  • isIndexedDBError (67-111)
🪛 Biome (2.1.2)
lib/storage/idb-keyval.ts

[error] 345-345: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.

Hooks should not be called after an early return.

For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level

(lint/correctness/useHookAtTopLevel)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
next.config.mjs (1)

181-196: LGTM - Webpack and Turbopack aliases correctly configured.

The idb-keyval alias is properly set up for both bundlers, enabling consistent module resolution across client/server builds. The path styles differ appropriately: absolute for webpack, relative for turbopack.

instrumentation-client.ts (1)

166-173: LGTM - Enhanced IndexedDB error detection via derived message.

The expanded condition now catches IndexedDB errors from both the error object and the derived message string. This aligns with isIndexedDBError accepting both Error and string types, providing more robust error classification. Based on learnings, error filtering in beforeSend is the correct approach for client-side instrumentation.

lib/storage/idb-keyval.ts (4)

1-54: LGTM - Well-structured type definitions and utility functions.

The StoreFn type, RequestLike interface, error extraction helpers, and promisifyRequest are correctly implemented. The error detection patterns align with existing patterns in utils/error-sanitizer.ts.


56-114: LGTM - Robust database connection management with proper cache invalidation.

The connection pooling correctly handles close and versionchange events to invalidate stale connections. Failed connection attempts are properly removed from the cache.


116-154: LGTM - Retry logic for transient database-closing errors.

The createStore function correctly implements a single-retry pattern for InvalidStateError / "database connection is closing" scenarios, which can occur when the database is being upgraded or closed by another tab.


156-288: LGTM - CRUD operations correctly implemented.

The operations properly use transaction modes (readonly vs readwrite) and await transaction completion via promisifyRequest(store.transaction). The update function's rejectOnce pattern correctly prevents double-rejection.

Comment thread lib/storage/idb-keyval.ts
Signed-off-by: Simo <simo@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

@simo6529 simo6529 merged commit 5f9c70e into main Dec 17, 2025
8 checks passed
@simo6529 simo6529 deleted the sentry-3 branch December 17, 2025 11:06
@coderabbitai coderabbitai Bot mentioned this pull request Mar 16, 2026
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.

2 participants