Skip to content

Conversation

@aguxez
Copy link
Contributor

@aguxez aguxez commented Jan 5, 2026

Summary by CodeRabbit

  • New Features

    • Webhook subscription updates now enqueue to a background worker for asynchronous processing.
    • Background queue and worker with graceful shutdown integrated into server lifecycle.
  • Tests

    • Added unit tests covering the queue processor and credential-creation enqueue behavior (success, unknown-job, and API-failure scenarios).
  • Chores

    • Added release metadata and updated environment/shutdown settings to support the new worker setup.

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


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: 838c475

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a BullMQ alchemy queue/worker, enqueues webhook-update jobs from credential creation, wires queue shutdown into server close, updates local script env, and adds unit tests and a changeset for a patch release.

Changes

Cohort / File(s) Summary
Queue constants
server/queues/constants.ts
Adds QueueName and AlchemyJob constants and derived union types.
Alchemy queue implementation
server/queues/alchemyQueue.ts
New BullMQ Queue and optional Worker, AlchemyJobData type, processor handling ADD_SUBSCRIBER, Redis connection from REDIS_URL, worker event handlers, and close() to shut down resources.
Credential creation integration
server/utils/createCredential.ts
Signature changed to (c, credentialId, options?); replaces direct webhook update with alchemyQueue.add(AlchemyJob.ADD_SUBSCRIBER, { account, webhookId }) when webhookId exists and captures enqueue errors.
Server shutdown & script env
server/index.ts, server/script/openapi.ts
Imports and calls queue close() in shutdown; server/script/openapi.ts sets REDIS_URL="redis://127.0.0.1:6379" and DISABLE_WORKERS="true".
Tests
server/test/queues/alchemyQueue.test.ts, server/test/utils/createCredential.test.ts
Adds unit tests: queue processor behavior (PATCH, error, unknown job) and createCredential enqueue behavior, error handling, and no-webhook case.
Changeset
.changeset/short-cars-return.md
Adds changeset declaring a patch release for @exactly/server with description "✨ add queue on user creation".

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant CreateCred as createCredential()
    participant Queue as alchemyQueue
    participant Redis as Redis
    participant Worker as alchemyWorker
    participant Sentry as Sentry
    participant AlchemyAPI as Alchemy API

    User->>CreateCred: create credential (account, webhookId)
    CreateCred->>Queue: add(ADD_SUBSCRIBER, {account, webhookId})
    Queue->>Redis: persist job
    Redis-->>Queue: job enqueued
    Worker->>Redis: fetch job
    Redis-->>Worker: deliver job
    Worker->>Sentry: startSpan("alchemy.processor")
    Worker->>AlchemyAPI: PATCH /v1/webhooks/{webhookId} (addresses)
    alt API success
        AlchemyAPI-->>Worker: 200 OK
        Worker->>Sentry: breadcrumb/completed
    else API failure
        AlchemyAPI-->>Worker: non-OK
        Worker->>Sentry: recordException + set tag
        Worker-->>Queue: mark job failed
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • cruzdanilo
  • nfmelendez
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly describes the main change: implementing a queue system for processing webhook updates on user credential creation. The emoji and concise phrasing accurately reflect the core objective of this changeset.

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

✨ 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 feature/webhook-queue

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @aguxez, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust queueing system for handling Alchemy webhook subscription updates. By integrating BullMQ, the application now processes these updates asynchronously, moving the task from the main request-response cycle to a background worker. This change enhances the system's reliability and performance by preventing blocking operations and providing built-in retry capabilities for external API calls, particularly when a new user credential is created.

Highlights

  • Introduction of Alchemy Queue: A new BullMQ queue (alchemyQueue) and its worker are implemented to manage Alchemy-related background tasks, specifically for updating webhook subscriptions.
  • Asynchronous Webhook Updates: The process of adding a subscriber to an Alchemy webhook is now offloaded from the main thread to the alchemyQueue, improving responsiveness and enabling retry mechanisms.
  • Refactoring createCredential: The createCredential utility function no longer directly calls the Alchemy API; instead, it enqueues an ADD_SUBSCRIBER job to the alchemyQueue.
  • New Queue Constants: Dedicated constants (QueueName and AlchemyJob) are introduced for better organization and type safety of queue names and job types.
  • Testing for Queue Functionality: New test files (alchemyQueue.test.ts and createCredential.test.ts) have been added to ensure the correct behavior of the Alchemy queue processor and its integration with credential creation.
  • Environment Configuration Update: The openapi.ts script now explicitly sets REDIS_URL and DISABLE_WORKERS to manage worker initialization during schema generation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a background job queue using BullMQ and Redis to handle Alchemy webhook subscription updates upon user creation. This change refactors the createCredential function to offload the synchronous API call to Alchemy into an asynchronous job. This improves the endpoint's response time and adds resilience through automatic retries on failure. The changes include new files for the queue, worker, and constants, along with corresponding tests. My review provides suggestions to improve the robustness of the queue worker, enhance test coverage for error scenarios, and increase code conciseness.

Copy link

@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: 6

Fix all issues with AI Agents 🤖
In @server/queues/alchemyQueue.ts:
- Line 61: Replace the direct process.env access in the conditional that checks
DISABLE_WORKERS inside alchemyQueue.ts: instead accept a configuration value
(e.g., a boolean like disableWorkers) injected from startup config and use that
variable in the if check instead of process.env.DISABLE_WORKERS; modify the
module API (exported initializer or constructor function) to receive the config
from the app bootstrap where env is loaded once, and update any call sites to
pass the injected config value. Ensure the unique symbol referenced is the
conditional that currently uses process.env.DISABLE_WORKERS and the module's
public initialization function (or top-level export) is updated to accept the
config.
- Around line 18-23: The code directly reads process.env to build the Redis
connection (the const connection) and uses Number() for the port; change this to
accept a Redis config object injected at module initialization (e.g., add a
factory function like createAlchemyQueue(redisConfig) or export a setter that
receives redisConfig) and construct the connection from that injected config
instead of process.env, and parse the port with Number.parseInt(redisConfig.port
?? "6379", 10) rather than Number(); update all uses of the existing connection
constant to obtain it from the factory/initializer you add.
- Around line 38-57: The span.setStatus call in processor currently uses the
magic number 2; replace this with a named Sentry status constant (e.g.,
SpanStatus or Sentry.SpanStatus/SpanStatusType) to improve clarity: import the
appropriate enum from the Sentry package used in the project and call
span.setStatus({ code: SpanStatus.InternalError }) or the equivalent named
member instead of using the literal 2; update the import and the span.setStatus
invocation in the processor function and ensure any type references (Span,
startSpan) remain compatible.

In @server/test/queues/alchemyQueue.test.ts:
- Around line 39-66: The test contains an unnecessary type assertion on the
headers expectation; in the AlchemyQueue test where you call processor and
assert fetch was called, remove the "as unknown as Record<string, string>" cast
on the expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) expression
so the matcher is used directly; keep the rest of the
expect.objectContaining(...) structure intact and run the tests to ensure
type/compile issues are resolved.

In @server/test/utils/createCredential.test.ts:
- Around line 59-71: Remove the unnecessary type assertion on the
expect.stringMatching call in the test: in the "should add a job to alchemyQueue
when credential is created" case, update the assertion that checks
alchemyQueue.add was called with AlchemyJob.ADD_SUBSCRIBER so the account
property uses expect.stringMatching(/^0x/) directly (remove the "as unknown as
string" cast); this change touches the test around createCredential,
mockContext, credentialId and the alchemyQueue.add expectation.

In @server/utils/createCredential.ts:
- Around line 54-56: The captureException call for the
alchemyQueue.add(AlchemyJob.ADD_SUBSCRIBER, { account, webhookId }) promise
rejection should include the same error-level metadata used elsewhere; update
the anonymous catch handler to call captureException(error, { level: "error" })
so the AlchemyJob.ADD_SUBSCRIBER error is logged with a consistent severity
level like the Sardine capture.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e7015c and 6b2047a.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/script/openapi.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/script/openapi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/script/openapi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/script/openapi.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/script/openapi.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/script/openapi.ts
🧠 Learnings (4)
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
🧬 Code graph analysis (4)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/test/utils/createCredential.test.ts (3)
server/utils/createCredential.ts (1)
  • createCredential (24-63)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (30-30)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (30-30)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/queues/alchemyQueue.test.ts (2)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (11-16)
  • processor (38-57)
🔇 Additional comments (11)
server/script/openapi.ts (1)

25-26: LGTM: Environment configuration updated for queue support.

The Redis URL format and worker disabling flag are appropriate for the OpenAPI generation script context. These changes align with the new queue infrastructure while preventing worker initialization during spec generation.

.changeset/short-cars-return.md (1)

1-5: LGTM: Changeset follows conventions.

The changeset format and description are correct, using lowercase imperative present tense as required by coding guidelines.

server/test/utils/createCredential.test.ts (2)

9-50: LGTM: Comprehensive mock setup.

The mocks appropriately cover all dependencies required for testing the queue integration, including database, Sentry, cookies, and external services.


73-81: LGTM: Error handling properly tested.

The test correctly validates that queue failures are captured via Sentry, ensuring observability of background job issues.

server/utils/createCredential.ts (1)

1-22: LGTM: Imports properly organized.

The import changes correctly add queue dependencies and organize external libraries before relative paths as required by coding guidelines.

server/test/queues/alchemyQueue.test.ts (2)

8-32: LGTM: Mock setup properly simulates dependencies.

The mocks correctly simulate Alchemy API headers, webhook IDs, Sentry tracing, and HTTP responses needed for processor testing.


68-77: LGTM: Unknown job handling properly tested.

The test correctly validates that unknown job names are gracefully ignored while maintaining observability through Sentry spans.

server/queues/constants.ts (1)

1-11: LGTM! Well-structured constants and types.

The use of as const with derived type aliases provides excellent type safety for queue and job identifiers throughout the application. The naming conventions are clear and consistent.

server/queues/alchemyQueue.ts (3)

8-16: LGTM! Clear interface definition.

The JSDoc comments follow the lowercase convention and provide helpful context for the data structure.


25-30: Queue setup looks good once connection configuration is addressed.

The queue initialization is properly structured. The comment effectively explains the purpose of the queue.


62-87: Excellent Worker configuration and observability.

The Worker setup demonstrates good practices:

  • Rate limiting with reasonable defaults
  • Comprehensive error handling with Sentry integration
  • Breadcrumbs on lifecycle events for debugging

@aguxez aguxez force-pushed the feature/webhook-queue branch 2 times, most recently from 32c8a33 to 0dc7771 Compare January 6, 2026 12:00
Copy link

@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: 3

🤖 Fix all issues with AI Agents
In @server/queues/alchemyQueue.ts:
- Around line 10-14: The code directly reads process.env to set disableWorkers
and Redis configuration; refactor to remove direct env access by creating a
factory initializer (e.g., createAlchemyQueue) that accepts an
AlchemyQueueConfig containing disableWorkers and a redis config object, use that
config to construct the Redis connection or host/port and to instantiate the
Queue (QueueName.ALCHEMY) and worker conditional logic, and update all places
using the disableWorkers variable or inline Redis creation to use the injected
config instead so configuration is loaded once at startup and passed in.

In @server/test/queues/alchemyQueue.test.ts:
- Line 54: Remove the redundant type assertion on the headers expectation in the
test: replace the line using headers: expect.objectContaining({
"X-Alchemy-Token": "mock-token" }) as Record<string, string> with headers:
expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) (i.e., delete the
"as Record<string, string>" cast) so the matcher types from
expect.objectContaining() are used directly.
- Around line 68-77: The test should be updated to expect the processor to throw
for unknown job names (the processor's default path throws Error("Unknown job
name: unknown")). Replace the current await processor(job) with await
expect(processor(job)).rejects.toThrow("Unknown job name: unknown"); and keep
the existing assertions that startSpan was called with expect.objectContaining({
name: "alchemy.processor", op: "queue.process" }) and that fetch was not called,
so the test aligns with the processor function's behavior.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b2047a and 32c8a33.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (6)
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
🧬 Code graph analysis (3)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (38-38)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/queues/alchemyQueue.test.ts (2)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (19-24)
  • processor (46-73)
🪛 GitHub Actions: test
server/queues/alchemyQueue.ts

[error] 68-68: Unknown job name: unknown. Step: nx run @exactly/server:test:vi (vitest run).

server/test/queues/alchemyQueue.test.ts

[error] 1-1: getaddrinfo EAI_AGAIN redis (DNS resolution failure for Redis) during tests. Step: nx run @exactly/server:test:vi (vitest run).

🪛 GitHub Check: test
server/queues/alchemyQueue.ts

[failure] 68-68: test/queues/alchemyQueue.test.ts > alchemyQueue worker processor > should ignore unknown job names
Error: Unknown job name: unknown
❯ queues/alchemyQueue.ts:68:17
❯ test/queues/alchemyQueue.test.ts:22:7
❯ Module.processor queues/alchemyQueue.ts:47:10
❯ test/queues/alchemyQueue.test.ts:70:11

🔇 Additional comments (11)
server/script/openapi.ts (1)

25-26: LGTM! Environment configuration updated appropriately.

The REDIS_URL now uses a proper connection string format, and the DISABLE_WORKERS flag aligns with the queue worker system introduced in this PR.

.changeset/short-cars-return.md (1)

1-5: LGTM! Changeset follows guidelines.

The changeset correctly uses a patch-level bump and the description follows the required format: lowercase imperative present tense.

server/test/utils/createCredential.test.ts (2)

9-50: LGTM! Comprehensive mock setup.

The test properly mocks all external dependencies including the queue, database, Sentry, and network calls. The use of { spy: true } for Sentry allows verification of captureException calls while preserving the module structure.


73-82: LGTM! Error handling test is correct.

The test properly validates that exceptions from queue operations are captured by Sentry, ensuring observability of background job failures.

server/utils/createCredential.ts (2)

1-22: LGTM! Imports updated for queue-based architecture.

The import changes correctly separate Sentry concerns (setUser from core, captureException from node) and introduce the necessary queue infrastructure. All imports use relative paths as required.


24-61: LGTM! Queue-based architecture improves reliability.

The refactor from direct HTTP calls to background job enqueuing is well-implemented. Using Promise.all for parallel execution of non-blocking operations is appropriate, and the queue approach enables retry logic and better observability for webhook subscriptions.

server/queues/constants.ts (1)

1-11: LGTM! Clean constant definitions.

The const objects with as const and derived type unions provide a type-safe, enum-like pattern for queue and job names. The structure is clear and easily extensible for future queues or job types.

server/test/queues/alchemyQueue.test.ts (2)

39-66: Good test coverage for the happy path.

The test correctly validates the fetch call payload, HTTP method, headers, and Sentry span invocation for the ADD_SUBSCRIBER job.


79-95: Good coverage for API failure scenario.

This test validates that non-OK responses from the Alchemy API result in proper error propagation with the expected message format.

server/queues/alchemyQueue.ts (2)

46-73: Processor implementation is well-structured.

The switch statement with a default case that throws for unknown job names is a robust pattern. The Sentry span wrapping provides good observability. The inline comment /* this is an error code */ clarifies the magic number.


77-102: Worker initialization with lifecycle handlers looks good.

The event handlers for failed, completed, and active provide appropriate observability via Sentry breadcrumbs and exception capture. The limiter configuration (max: 10, duration: 1000) provides rate limiting.

One minor note: the new Worker(...) result is discarded. If you need to gracefully shut down the worker during application termination, consider storing a reference.

Copy link

@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: 5

🤖 Fix all issues with AI Agents
In @server/queues/alchemyQueue.ts:
- Around line 65-69: Update the test "should ignore unknown job names" to assert
that an error is thrown instead of expecting silent ignore: call the function
that processes jobs with an unknown job.name and change the assertion to expect
a rejection/throw (e.g., use expect(...).rejects.toThrow or expect(() =>
...).toThrow) for the error message matching `Unknown job name: ${job.name}` (or
assert span.setStatus was called with code 2 and the same message) so the test
aligns with the implementation that throws the Error constructed in the default
branch (errorMessage) and calls span.setStatus.
- Around line 78-102: The Worker instance created for QueueName.ALCHEMY is not
stored, preventing graceful shutdown; assign the new Worker(...) to a variable
(e.g., alchemyWorker) where it's instantiated (the call using QueueName.ALCHEMY,
processor, connection, limiter) and export or register that reference so
shutdown logic can call alchemyWorker?.close() (or await alchemyWorker.close())
during application termination to allow in-flight jobs to finish.

In @server/test/queues/alchemyQueue.test.ts:
- Around line 68-77: The test incorrectly assumes processor(job) resolves for
unknown job names; instead replace the direct await call with a Jest rejection
assertion: call await expect(processor(job)).rejects.toThrow() (keeping the
subsequent assertions about startSpan and fetch if still relevant) so the test
expects the processor to throw on an unknown job name; reference the processor
function, the job variable (name: "unknown"), startSpan and fetch in the updated
expectation.
- Around line 39-66: Remove the unnecessary type assertion on the headers
expectation in the test: in the "should call Alchemy API to update webhook
addresses" test where you call expect(fetch).toHaveBeenCalledWith(...), delete
the trailing "as Record<string, string>" after expect.objectContaining({
"X-Alchemy-Token": "mock-token" }) so the matcher reads
expect.objectContaining({ headers: expect.objectContaining({ "X-Alchemy-Token":
"mock-token" }) }), leaving the rest of the assertion (Job<AlchemyJobData>,
AlchemyJob.ADD_SUBSCRIBER, processor, and startSpan expectations) unchanged.

In @server/test/utils/createCredential.test.ts:
- Around line 59-71: Remove the unnecessary type assertion on the
expect.stringMatching result in the test for createCredential: modify the
assertion in the alchemyQueue.add expectation to use
expect.stringMatching(/^0x/) without "as string" (target the call to
alchemyQueue.add in the "should add a job to alchemyQueue when credential is
created" test that asserts AlchemyJob.ADD_SUBSCRIBER and objectContaining {
account: expect.stringMatching(/^0x/), webhookId: "webhook-id" }).
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b2047a and 0dc7771.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (6)
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
🧬 Code graph analysis (3)
server/test/queues/alchemyQueue.test.ts (3)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (19-24)
  • processor (46-73)
server/test/utils/createCredential.test.ts (3)
server/utils/createCredential.ts (1)
  • createCredential (24-61)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (38-38)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (38-38)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
🪛 GitHub Actions: test
server/test/queues/alchemyQueue.test.ts

[error] 22-22: Test failed: Unknown job name: unknown

server/queues/alchemyQueue.ts

[error] 68-68: Unknown job name: unknown

🪛 GitHub Check: test
server/queues/alchemyQueue.ts

[failure] 68-68: test/queues/alchemyQueue.test.ts > alchemyQueue worker processor > should ignore unknown job names
Error: Unknown job name: unknown
❯ queues/alchemyQueue.ts:68:17
❯ test/queues/alchemyQueue.test.ts:22:7
❯ Module.processor queues/alchemyQueue.ts:47:10
❯ test/queues/alchemyQueue.test.ts:70:11

🔇 Additional comments (7)
server/script/openapi.ts (1)

25-26: LGTM: Environment configuration aligns with queue system requirements.

The Redis URL now uses the full connection string format required by ioredis/BullMQ, and DISABLE_WORKERS prevents background worker processes during OpenAPI spec generation. These changes are appropriate for the script context.

.changeset/short-cars-return.md (1)

1-5: LGTM: Changeset follows conventions.

The changeset format is correct, and the description follows the required lowercase imperative present tense style.

server/test/utils/createCredential.test.ts (1)

73-81: LGTM: Error handling test is comprehensive.

The test correctly verifies that queue failures are captured via Sentry's captureException, ensuring resilient error handling in the credential creation flow.

server/queues/constants.ts (1)

1-11: LGTM: Clean constant definitions following TypeScript best practices.

The use of as const with type extraction via indexed access types is idiomatic and type-safe. The naming is clear and follows conventions.

server/test/queues/alchemyQueue.test.ts (1)

79-95: LGTM: API failure test validates error propagation.

The test correctly verifies that non-OK responses from the Alchemy API result in the processor rejecting with the appropriate error message.

server/queues/alchemyQueue.ts (2)

46-73: LGTM - Processor implementation is well-structured.

The switch statement pattern with a default case that throws for unknown job names is a good defensive approach for catching typos and ensuring new job types are explicitly handled. The Sentry span tracing provides good observability.


19-24: LGTM - Interface is well-documented.

The AlchemyJobData interface provides clear documentation for the job payload structure.

@aguxez aguxez force-pushed the feature/webhook-queue branch from 0dc7771 to 63b777f Compare January 6, 2026 12:28
@sentry
Copy link

sentry bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.84%. Comparing base (3430400) to head (838c475).

Files with missing lines Patch % Lines
server/queues/alchemyQueue.ts 73.07% 5 Missing and 2 partials ⚠️
server/utils/createCredential.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #619       +/-   ##
===========================================
+ Coverage   61.88%   79.84%   +17.95%     
===========================================
  Files         169       47      -122     
  Lines        5289     2148     -3141     
  Branches     1496      484     -1012     
===========================================
- Hits         3273     1715     -1558     
+ Misses       1844      275     -1569     
+ Partials      172      158       -14     
Flag Coverage Δ
e2e 79.84% <73.33%> (+19.77%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@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

🤖 Fix all issues with AI Agents
In @server/queues/alchemyQueue.ts:
- Around line 60-62: The default branch in the processor currently only sets
span.setStatus({ code: 2, message: `unknown job name: ${job.name}` }) but
doesn't throw, so unknown job names silently succeed; change the default in the
switch inside processor to throw a new Error(`unknown job name: ${job.name}`)
after setting the span status so the job fails fast (keep the span.setStatus
call), and update the test in server/test/queues/alchemyQueue.test.ts to expect
processor(job) to reject with that error.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc7771 and 63b777f.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/script/openapi.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/script/openapi.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/script/openapi.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/script/openapi.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/script/openapi.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/script/openapi.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (6)
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/script/openapi.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
🧬 Code graph analysis (4)
server/test/utils/createCredential.test.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (33-33)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (33-33)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/queues/alchemyQueue.test.ts (2)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (14-19)
  • processor (41-65)
🔇 Additional comments (7)
server/script/openapi.ts (1)

25-26: LGTM!

The updated REDIS_URL format and DISABLE_WORKERS flag are appropriate for the OpenAPI spec generation script. Disabling workers prevents unnecessary Redis connections during build-time spec generation. Based on learnings, this script context (not application code) is acceptable for direct process.env usage.

server/queues/constants.ts (1)

1-11: LGTM!

Well-structured constants with proper type derivation using as const. The pattern of deriving types from constant objects ensures type safety and maintains a single source of truth.

.changeset/short-cars-return.md (1)

1-5: LGTM!

Changeset follows guidelines with lowercase imperative present tense description. Patch level is appropriate for this additive feature.

server/test/utils/createCredential.test.ts (1)

52-82: LGTM!

Good test coverage for the queue integration: verifies job enqueueing on credential creation and proper error capture when the queue fails.

server/test/queues/alchemyQueue.test.ts (2)

68-77: Test expectation should change if processor is updated.

This test currently expects unknown jobs to be silently ignored, which matches the current implementation. However, if the processor is updated to throw on unknown job names (as recommended in the alchemyQueue.ts review), update this test to expect the error:

it("should throw an error for unknown job names", async () => {
  const job = { name: "unknown", data: {} } as unknown as Job<AlchemyJobData>;
  await expect(processor(job)).rejects.toThrow("unknown job name: unknown");
  expect(fetch).not.toHaveBeenCalled();
});

39-66: LGTM!

Good test coverage for the processor: verifies correct API call construction for ADD_SUBSCRIBER jobs, proper Sentry span creation, and error handling when the Alchemy API fails.

Also applies to: 79-95

server/utils/createCredential.ts (1)

21-22: LGTM!

Good refactoring from synchronous HTTP calls to queue-based processing. The fire-and-forget pattern with error capture is appropriate for non-critical webhook subscription updates, and the queue provides retry capability on failures.

Also applies to: 54-54

@cruzdanilo
Copy link
Member

@cursor review

@cursor
Copy link

cursor bot commented Jan 6, 2026

PR Summary

Cursor Bugbot is generating a summary for commit 63b777f. Configure here.

@cursor
Copy link

cursor bot commented Jan 6, 2026

PR Summary

Introduces background processing for Alchemy webhook address updates and wires it into credential creation.

  • Adds bullmq queue/worker (alchemyQueue, processor) with Sentry tracing and Redis config; supports disabling workers via DISABLE_WORKERS
  • createCredential now enqueues AlchemyJob.ADD_SUBSCRIBER instead of calling Alchemy directly
  • Adds tests for queue processor and createCredential queuing behavior; updates openapi script env to set REDIS_URL and DISABLE_WORKERS

Written by Cursor Bugbot for commit 63b777f. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 2

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@aguxez aguxez force-pushed the feature/webhook-queue branch from 63b777f to 03cbfe4 Compare January 7, 2026 11:05
@aguxez aguxez force-pushed the feature/webhook-queue branch from 03cbfe4 to 54b79be Compare January 7, 2026 11:12
Copy link

@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: 6

🤖 Fix all issues with AI agents
In @server/queues/alchemyQueue.ts:
- Line 9: The file directly reads process.env.DISABLE_WORKERS into the const
disableWorkers which violates the rule to not access process.env in application
code; change the module to accept configuration via dependency injection (e.g.,
export a factory like createAlchemyQueue(config) or accept a Config parameter)
and replace direct usage of disableWorkers with config.disableWorkers (or
equivalent) throughout the file so configuration is loaded once at startup and
passed in rather than read from process.env inside this module.
- Around line 21-26: The code directly reads process.env to build the Redis
`connection` object and uses Number() for port parsing; change this by
introducing a factory function (e.g., export function
createRedisConnection(redisConfig: { url?: string; host?: string; port?: string
| number })) that takes the preloaded config instead of accessing process.env
inside this module, and inside that function build the connection: if
redisConfig.url use new Redis(redisConfig.url, { maxRetriesPerRequest: null }),
otherwise use { host: redisConfig.host ?? "localhost", port:
Number.parseInt(String(redisConfig.port ?? "6379"), 10) }; update call sites to
pass the startup-loaded config into createRedisConnection instead of relying on
environment access here.
- Around line 41-68: The span.setStatus calls in processor (inside the
AlchemyJob.ADD_SUBSCRIBER case and the default case) use the magic number 2;
replace that literal with a named constant or the Sentry enum (e.g., import
SpanStatusCode from "@sentry/node" and use SpanStatusCode.Error) or define a
local constant like SPAN_STATUS_ERROR and use it in both span.setStatus calls to
improve readability and consistency.
- Around line 72-100: The Worker instance created for QueueName.ALCHEMY is not
stored, preventing graceful shutdown; assign it to a module-scoped variable
(e.g., let alchemyWorker: Worker | undefined = new Worker(...) or create it then
set alchemyWorker = worker) so you can call alchemyWorker?.close() during
application termination/shutdown handling; ensure the variable is exported or
accessible by your existing shutdown routine and keep existing event handlers
(.on("failed"/"completed"/"active"/"error")) attached to the stored worker.

In @server/test/queues/alchemyQueue.test.ts:
- Line 54: The test assertion includes an unnecessary type assertion on the
headers matcher; remove the trailing "as Record<string, string>" from the
headers line so the matcher uses expect.objectContaining({ "X-Alchemy-Token":
"mock-token" }) directly (update the headers property in the assertion where
expect.objectContaining is used).

In @server/test/utils/createCredential.test.ts:
- Line 67: Remove the redundant type assertion on the account matcher: locate
the object assigning account: expect.stringMatching(/^0x/) as string and simply
use account: expect.stringMatching(/^0x/); the expect.stringMatching call
already returns the correct matcher type so drop the "as string" cast to clean
up the test.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63b777f and 54b79be.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (6)
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/script/openapi.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
🧬 Code graph analysis (3)
server/test/queues/alchemyQueue.test.ts (1)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (14-19)
  • processor (41-68)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (33-33)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
🔇 Additional comments (12)
server/queues/constants.ts (1)

1-11: LGTM! Clean constants definition.

The use of as const with derived enum types is idiomatic TypeScript, providing strong type safety for queue and job names.

server/script/openapi.ts (1)

25-26: LGTM! Appropriate environment configuration for OpenAPI generation.

The explicit Redis URL and DISABLE_WORKERS flag correctly prevent worker initialization during spec generation while maintaining the zero-config local dev environment.

.changeset/short-cars-return.md (1)

1-5: LGTM! Changeset follows the required format.

The summary correctly uses lowercase imperative present tense as per coding guidelines.

server/test/utils/createCredential.test.ts (1)

1-58: LGTM! Comprehensive test coverage with proper mocking.

The test suite correctly validates both the happy path (job enqueuing) and error handling (exception capture), with well-isolated mocks.

Also applies to: 72-82

server/test/queues/alchemyQueue.test.ts (1)

1-53: LGTM! Comprehensive test coverage for queue processor.

The test suite validates all critical paths: successful webhook updates, unknown job handling, and API failure scenarios. The tests correctly expect the processor to throw errors for edge cases.

Also applies to: 55-90

server/utils/createCredential.ts (4)

6-7: LGTM!

The Sentry import changes appropriately separate setUser from @sentry/core and captureException from @sentry/node, following the modular structure of the Sentry SDK.


14-14: LGTM!

The database import addition is necessary for the database operations and follows the project's import conventions.


21-22: LGTM!

The queue-related imports are correctly added to support the new asynchronous job enqueueing approach, replacing the previous synchronous HTTP call.


54-54: Consider consistent error capture options.

The captureException call at line 54 doesn't include a level option, while the similar sardine error capture at line 56 specifies { level: "error" }. For consistency, consider adding the same error level to both non-critical async operations.

🔎 Suggested consistency improvement
-    alchemyQueue.add(AlchemyJob.ADD_SUBSCRIBER, { account, webhookId }).catch(captureException),
+    alchemyQueue.add(AlchemyJob.ADD_SUBSCRIBER, { account, webhookId }).catch((error: unknown) =>
+      captureException(error, { level: "error" }),
+    ),

Likely an incorrect or invalid review comment.

server/queues/alchemyQueue.ts (3)

1-6: LGTM!

The imports are correctly structured with proper type imports and necessary dependencies for the queue implementation.


11-19: LGTM!

The AlchemyJobData interface is well-documented with clear JSDoc comments explaining each field's purpose.


28-33: LGTM!

The queue is correctly instantiated with proper documentation explaining its purpose for offloading webhook subscription updates and enabling retries.

@aguxez aguxez force-pushed the feature/webhook-queue branch from 54b79be to 61cb4bb Compare January 7, 2026 11:32
Copy link

@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: 2

🤖 Fix all issues with AI agents
In @server/test/queues/alchemyQueue.test.ts:
- Line 54: The test contains an unnecessary type assertion on the headers
matcher: remove the trailing "as Record<string, string>" from the
expect.objectContaining call (the matcher returned by expect.objectContaining({
"X-Alchemy-Token": "mock-token" }) is already correctly typed); update the line
using the headers matcher (the expression starting with
expect.objectContaining({ "X-Alchemy-Token": "mock-token" })) to omit the cast
and run tests to confirm no type errors remain.

In @server/test/utils/createCredential.test.ts:
- Line 67: Remove the redundant type assertion on the account matcher: replace
the property value "expect.stringMatching(/^0x/) as string" with just
"expect.stringMatching(/^0x/)" in the createCredential.test.ts test (the object
property named account), since expect.stringMatching already returns the correct
matcher type.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54b79be and 61cb4bb.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
  • server/utils/createCredential.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/test/utils/createCredential.test.ts
🧠 Learnings (6)
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
🧬 Code graph analysis (4)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (33-33)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/queues/alchemyQueue.test.ts (3)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (14-19)
  • processor (41-68)
server/test/utils/createCredential.test.ts (3)
server/utils/createCredential.ts (1)
  • createCredential (24-61)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (33-33)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
🔇 Additional comments (9)
server/script/openapi.ts (1)

25-26: LGTM! Environment configuration aligns with new queue infrastructure.

The Redis URL now provides a proper connection string for local development, and the DISABLE_WORKERS flag enables control over worker initialization during spec generation.

.changeset/short-cars-return.md (1)

1-5: LGTM! Changeset follows guidelines.

The description uses lowercase imperative present tense as required by the coding guidelines.

server/test/utils/createCredential.test.ts (1)

1-82: LGTM! Test coverage is comprehensive.

The tests appropriately cover both the success path (job enqueuing) and error path (exception capture), with thorough mocking of dependencies.

server/queues/constants.ts (1)

1-11: LGTM! Clean constants definition.

The constants follow TypeScript best practices with as const assertions and proper type derivation. Naming conventions are correct throughout.

server/test/queues/alchemyQueue.test.ts (1)

1-90: LGTM! Comprehensive test coverage for the queue processor.

The tests cover all critical paths: successful processing, unknown job handling, and API failure scenarios. The mocking strategy is thorough and appropriate.

server/utils/createCredential.ts (1)

46-59: Queue-based approach for webhook subscription looks good.

The switch from synchronous HTTP PATCH to asynchronous queue processing improves reliability by enabling retries on API failures and avoids blocking the main request flow. The Promise.all correctly handles the concurrent operations with appropriate error capture.

server/queues/alchemyQueue.ts (3)

60-64: Unknown job handling now correctly throws - good fix.

The default case properly sets the span status and throws an error, ensuring unknown jobs fail fast rather than silently succeeding. This addresses the previous feedback about silent failures.


98-99: Error handler addition prevents process crashes - good fix.

The .on("error") handler correctly captures Redis connection failures and internal errors, preventing uncaught exceptions from crashing the process. This follows the pattern used elsewhere in the codebase (e.g., analytics.on("error", ...) in segment.ts).


41-68: Processor implementation is well-structured.

The processor correctly:

  • Uses Sentry tracing with appropriate span attributes
  • Handles the ADD_SUBSCRIBER job type with proper API call
  • Throws on non-ok responses with status details
  • Throws on unknown job names for fail-fast behavior

@aguxez aguxez force-pushed the feature/webhook-queue branch 3 times, most recently from f9b7be5 to 5e59af2 Compare January 7, 2026 13:53
Copy link

@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: 3

🤖 Fix all issues with AI agents
In @.changeset/short-cars-return.md:
- Line 5: Update the changelog summary in .changeset/short-cars-return.md by
removing the redundant "server:" prefix so the summary reads "add queue on user
creation" (i.e., replace "server: add queue on user creation" with "add queue on
user creation").

In @server/test/queues/alchemyQueue.test.ts:
- Line 54: Remove the redundant type assertion by deleting "as Record<string,
string>" from the headers matcher so it reads headers: expect.objectContaining({
"X-Alchemy-Token": "mock-token" }); leave the expect.objectContaining() usage
intact (in the test that sets headers) since Vitest will infer the matcher types
correctly.

In @server/test/utils/createCredential.test.ts:
- Line 67: The test includes a redundant type assertion on the account property:
remove the unnecessary "as string" cast and rely on expect.stringMatching(/^0x/)
directly (i.e., replace "account: expect.stringMatching(/^0x/) as string" with
"account: expect.stringMatching(/^0x/)" in the test using
expect.stringMatching).
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61cb4bb and 5e59af2.

📒 Files selected for processing (7)
  • .changeset/short-cars-return.md
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/utils/createCredential.test.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/utils/createCredential.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/utils/createCredential.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/utils/createCredential.test.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/utils/createCredential.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/script/openapi.ts
  • server/queues/constants.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/test/utils/createCredential.test.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (6)
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/script/openapi.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
🧬 Code graph analysis (4)
server/test/queues/alchemyQueue.test.ts (3)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (15-20)
  • processor (42-69)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (2)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (34-34)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/utils/createCredential.test.ts (4)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/utils/createCredential.ts (1)
  • createCredential (24-61)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (34-34)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
🔇 Additional comments (5)
server/script/openapi.ts (1)

25-26: LGTM!

The REDIS_URL change to a full URL format is more explicit, and adding DISABLE_WORKERS prevents the queue worker from starting during OpenAPI spec generation, which is appropriate for this tooling script.

server/test/utils/createCredential.test.ts (1)

73-81: LGTM!

The exception handling test correctly verifies that queue failures are captured via Sentry's captureException, ensuring observability for background job enqueue failures.

server/queues/constants.ts (1)

1-11: LGTM!

Clean constants definition following TypeScript best practices. The use of as const for literal types and indexed access types for enums ensures type safety throughout the queue system.

server/test/queues/alchemyQueue.test.ts (2)

68-71: LGTM!

The test correctly validates that the processor throws an error for unknown job names, aligning with the processor's default case behavior.


73-89: LGTM!

Excellent addition of the API failure test case. This ensures the processor correctly handles and reports non-ok responses from the Alchemy API, improving resilience and observability.

@aguxez aguxez force-pushed the feature/webhook-queue branch from 5e59af2 to fdc90ad Compare January 7, 2026 18:15
@aguxez aguxez force-pushed the feature/webhook-queue branch 2 times, most recently from b0a759e to 05d805c Compare January 15, 2026 22:53
@aguxez aguxez force-pushed the feature/webhook-queue branch from 05d805c to bc4a358 Compare January 15, 2026 23:06
@aguxez aguxez force-pushed the feature/webhook-queue branch from bc4a358 to 8b4a018 Compare January 15, 2026 23:15
@aguxez aguxez force-pushed the feature/webhook-queue branch 3 times, most recently from 028ca68 to f56af9b Compare January 16, 2026 15:44
Copy link

@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: 3

🤖 Fix all issues with AI agents
In `@server/queues/alchemyQueue.ts`:
- Around line 12-19: The JSDoc comments for the AlchemyJobData interface use
sentence-case; update them to follow the project's lowercase comment style by
changing phrases like "The likely Ethereum address of the account to subscribe."
and "The Alchemy webhook ID to update." to fully lowercase variants (and do the
same for the comments at lines 69-70) so the interface name AlchemyJobData and
surrounding doc comments conform to the lowercase comment guideline.
- Around line 38-65: The processor is currently an async arrow function; per
style guide, convert it to a named async function declaration (e.g., async
function processor(job: Job<AlchemyJobData>) { ... }) while preserving the
existing logic inside the startSpan call and all references to
AlchemyJob.ADD_SUBSCRIBER, startSpan, span.setStatus, and thrown Errors; ensure
exports remain the same (export const processor -> export { processor } or
export function processor) and keep types/signatures and behavior unchanged.

In `@server/test/utils/createCredential.test.ts`:
- Around line 93-98: Remove the unnecessary type assertion in the test
expectation: in the assertion using expect.objectContaining({ level: "error",
extra: expect.objectContaining({ job: AlchemyJob.ADD_SUBSCRIBER, webhookId:
"webhook-id", }) as Record<string, unknown>, }) remove the trailing "as
Record<string, unknown>" so the matcher uses its own inferred type; update the
line in createCredential.test.ts accordingly and run the tests to confirm
nothing else needs adjusting.
♻️ Duplicate comments (5)
server/test/queues/alchemyQueue.test.ts (2)

1-6: Ensure Redis isn’t touched during unit tests. Importing alchemyQueue constructs a Redis connection immediately; set DISABLE_WORKERS (and a dummy REDIS_URL) before the import or mock the module to avoid CI failures.
As per coding guidelines.

Please verify test setup with:

#!/bin/bash
# Check whether DISABLE_WORKERS/REDIS_URL are set in test setup or configs
rg -n "DISABLE_WORKERS|REDIS_URL" vitest.config.* server/test

49-54: Remove redundant Record<string, string> cast. The matcher already satisfies the type.
As per coding guidelines.

♻️ Proposed simplification
-        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) as Record<string, string>,
+        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }),
server/test/utils/createCredential.test.ts (1)

75-80: Drop the redundant matcher cast. expect.stringMatching already yields a valid matcher type here.
As per coding guidelines.

♻️ Proposed simplification
-        account: expect.stringMatching(/^0x/) as string,
+        account: expect.stringMatching(/^0x/),
server/queues/alchemyQueue.ts (2)

9-24: Avoid direct process.env access in application modules. Load configuration once at startup and inject it into this module instead of reading DISABLE_WORKERS and REDIS_URL here.
As per coding guidelines.


22-24: Producer calls may hang with maxRetriesPerRequest: null. This can block user-facing requests when Redis is unavailable; consider a bounded retry strategy for producer connections (or separate producer/worker connections).

BullMQ ioredis maxRetriesPerRequest recommendation for producers vs workers
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0a759e and f56af9b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .changeset/short-cars-return.md
  • server/index.ts
  • server/package.json
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/test/utils/pax.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/test/utils/pax.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/test/utils/pax.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/test/utils/pax.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/test/utils/pax.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/test/utils/createCredential.test.ts
  • server/script/openapi.ts
  • server/test/utils/pax.test.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (19)
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2026-01-09T16:24:11.460Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 627
File: .changeset/breezy-planes-repeat.md:5-5
Timestamp: 2026-01-09T16:24:11.460Z
Learning: In the exactly/exa repository, changeset summaries in .changeset/*.md must start with a gitmoji and follow the format '<emoji> <message>' (no scope). This should mirror the commit message format '<emoji> <scope>: <message>' but omit the '<scope>:' portion. Ensure the message is clear and describes the change.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: Select the most precise gitmoji that best communicates the intent of the change (e.g., ✨ for new feature, 🐛 for bug fix, ♻️ for refactoring, ⚡️ for performance improvement, 📝 for documentation, 🚀 for deployment)

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Use gitmoji format for commits: `<emoji> <scope>: <message>` with scopes: `app`, `server`, `contracts`, `common`, `docs`

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: All commit messages must strictly adhere to the format: `<emoji> <scope>: <message>` where emoji is a gitmoji unicode character, scope is a mandatory short name (app, server, contracts, docs, common, dependencies, github, config, or repo), and message is a short lowercase description

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: All commits must start with a single gitmoji from the official gitmoji list; this is not optional and the emoji visually communicates the intent of the change

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/.changeset/*.md : Use a lowercase sentence in the imperative present tense for changeset summaries

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/script/openapi.ts
  • server/queues/alchemyQueue.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
📚 Learning: 2026-01-15T19:10:07.248Z
Learnt from: mainqueg
Repo: exactly/exa PR: 637
File: server/utils/persona.ts:155-160
Timestamp: 2026-01-15T19:10:07.248Z
Learning: In server/utils/persona.ts, the PERSONA_API_VERSION constant is intentionally set to "2023-01-05" to match the API version configured for the production API key in Persona's admin dashboard. This ensures consistent response behavior across different environments and should not be updated without also updating the production API key configuration.

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
  • server/package.json
📚 Learning: 2025-12-23T19:56:56.405Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/dev.mdc:0-0
Timestamp: 2025-12-23T19:56:56.405Z
Learning: Server (exactly/server) uses Hono (framework), Node.js, Drizzle ORM (database), and PostgreSQL

Applied to files:

  • server/package.json
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/queues/alchemyQueue.ts
  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Enforce Node.js best practices using ESLint `plugin:n/recommended` configuration

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/api/**/*.ts : Never instantiate or directly access a database client from within a route handler; it must be provided via context

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Do not use abbreviations or cryptic names; write out full words like `error`, `parameters`, `request` instead of `err`, `params`, `req`

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2026-01-15T19:06:40.947Z
Learnt from: mainqueg
Repo: exactly/exa PR: 637
File: server/hooks/persona.ts:186-195
Timestamp: 2026-01-15T19:06:40.947Z
Learning: In server/hooks/persona.ts, the webhook handler has intentionally different error handling for Manteca vs Panda flows: the Manteca path (payload.template === "manteca") lets addDocument errors propagate to enable webhook retries, while the Panda path uses .catch() to swallow addDocument errors and prevent retries since the user creation is already committed.

Applied to files:

  • server/utils/createCredential.ts
  • server/index.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/utils/createCredential.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Use Hono's built-in error handling by throwing `new HTTPException()` for expected errors; unhandled errors will be caught and logged automatically

Applied to files:

  • server/utils/createCredential.ts
🧬 Code graph analysis (5)
server/test/utils/createCredential.test.ts (2)
server/utils/createCredential.ts (1)
  • createCredential (24-68)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (5)
server/test/utils/createCredential.test.ts (1)
  • webhookId (46-48)
server/hooks/activity.ts (1)
  • webhookId (48-48)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (30-30)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/e2e.ts (1)
  • captureException (58-61)
server/index.ts (1)
server/queues/alchemyQueue.ts (1)
  • alchemyWorker (67-67)
server/test/queues/alchemyQueue.test.ts (3)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (15-20)
  • processor (38-65)
🔇 Additional comments (9)
server/script/openapi.ts (1)

28-29: LGTM!

The environment configuration changes are appropriate for OpenAPI generation:

  • REDIS_URL now uses a valid URL format matching the queue system's expectations.
  • DISABLE_WORKERS prevents background workers from starting during spec generation.
.changeset/short-cars-return.md (1)

1-5: LGTM!

The changeset follows the required format with the gitmoji prefix and lowercase imperative summary.

server/test/utils/pax.test.ts (1)

10-10: LGTM!

Using globalThis instead of global is the correct modern approach for accessing the global object, as it's the ECMAScript standard and works consistently across environments.

server/queues/constants.ts (1)

1-11: LGTM!

The constants follow TypeScript best practices:

  • as const preserves literal types for type safety.
  • Derived union types (QueueNameEnum, AlchemyJobEnum) are extensible when new values are added.
  • Pattern is preferable to TypeScript enums for tree-shaking and type inference.
server/package.json (1)

54-54: Document the reason for pinning ioredis to 5.9.1.

The version was pinned to exactly 5.9.1, which is 7 days older than the current latest 5.9.2 (released Jan 15, 2026). If this downgrade is intentional (e.g., due to a regression in 5.9.2), please add a comment explaining the reason. If unintentional, consider updating to the latest version.

server/index.ts (2)

18-18: Import looks good. The added queue worker import is appropriate for the updated shutdown flow.


288-293: Graceful shutdown now covers the worker. Awaiting alchemyWorker?.close() alongside other services is the right lifecycle behavior.

server/utils/createCredential.ts (2)

6-22: Imports align with the queue-based flow. Using captureException from @sentry/node and queue modules is consistent with the new design.


55-60: Queue enqueue is well-guarded and contextualized. The conditional plus enriched captureException metadata is solid.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@aguxez aguxez force-pushed the feature/webhook-queue branch from f56af9b to 222172e Compare January 16, 2026 16:15
Copy link

@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: 3

🤖 Fix all issues with AI agents
In `@server/package.json`:
- Line 54: The package.json change pins "ioredis" to 5.9.1 which unnecessarily
downgrades and removes semver flexibility; either revert this dependency to the
previous flexible version (e.g., change "ioredis": "5.9.1" back to "ioredis":
"^5.9.2") or, if the pin is intentional, add a clear comment in package.json or
the PR explaining the exact reason for pinning to 5.9.1 and why ioredis-mock
compatibility was insufficient; locate the "ioredis" entry in package.json to
make the change or add the explanatory comment.

In `@server/test/queues/alchemyQueue.test.ts`:
- Line 8: Change the comment "// Mock dependencies" to lowercase to follow the
style guide: replace it with "mock dependencies" in the alchemyQueue.test.ts
file (look for the top-of-file comment string "// Mock dependencies") so the
test file's comment text uses lowercase styling.

In `@server/test/utils/createCredential.test.ts`:
- Line 13: Replace the comment string "// Mock dependencies" with a lowercase
version "// mock dependencies" wherever it appears in the test (both occurrences
flagged in the review) so the comment text matches the project's style guide;
search for the exact comment token and update it to the lowercase form.
♻️ Duplicate comments (4)
server/test/utils/createCredential.test.ts (1)

75-81: Drop redundant matcher type assertions.
Vitest matchers already satisfy the expected types without casts.

♻️ Proposed fix
-        account: expect.stringMatching(/^0x/) as string,
+        account: expect.stringMatching(/^0x/),
-        }) as Record<string, unknown>,
+        }),

Also applies to: 91-99

server/test/queues/alchemyQueue.test.ts (1)

49-54: Remove unnecessary matcher type assertion.
Vitest’s matcher typing already covers this.

♻️ Proposed fix
-        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) as Record<string, string>,
+        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }),
server/queues/alchemyQueue.ts (2)

9-23: Avoid direct process.env reads in server modules.
Load configuration once at startup and inject it into this module (disableWorkers and Redis connection info) rather than reading environment variables here. As per coding guidelines.


23-30: Bound Redis retries for producer calls to avoid request hangs.
alchemyQueue.add() is invoked from user-facing flows; with maxRetriesPerRequest: null, Redis outages can stall those requests indefinitely. Consider separate connections (bounded retries for producer, unlimited for worker) or a small retry cap.

BullMQ / ioredis: recommended maxRetriesPerRequest values for producers vs workers
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f56af9b and 222172e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .changeset/short-cars-return.md
  • server/index.ts
  • server/package.json
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
  • server/script/openapi.ts
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
🧠 Learnings (24)
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/index.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
📚 Learning: 2026-01-15T19:06:40.947Z
Learnt from: mainqueg
Repo: exactly/exa PR: 637
File: server/hooks/persona.ts:186-195
Timestamp: 2026-01-15T19:06:40.947Z
Learning: In server/hooks/persona.ts, the webhook handler has intentionally different error handling for Manteca vs Panda flows: the Manteca path (payload.template === "manteca") lets addDocument errors propagate to enable webhook retries, while the Panda path uses .catch() to swallow addDocument errors and prevent retries since the user creation is already committed.

Applied to files:

  • server/index.ts
  • server/utils/createCredential.ts
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2026-01-09T16:24:11.460Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 627
File: .changeset/breezy-planes-repeat.md:5-5
Timestamp: 2026-01-09T16:24:11.460Z
Learning: In the exactly/exa repository, changeset summaries in .changeset/*.md must start with a gitmoji and follow the format '<emoji> <message>' (no scope). This should mirror the commit message format '<emoji> <scope>: <message>' but omit the '<scope>:' portion. Ensure the message is clear and describes the change.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: Select the most precise gitmoji that best communicates the intent of the change (e.g., ✨ for new feature, 🐛 for bug fix, ♻️ for refactoring, ⚡️ for performance improvement, 📝 for documentation, 🚀 for deployment)

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Use gitmoji format for commits: `<emoji> <scope>: <message>` with scopes: `app`, `server`, `contracts`, `common`, `docs`

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: All commit messages must strictly adhere to the format: `<emoji> <scope>: <message>` where emoji is a gitmoji unicode character, scope is a mandatory short name (app, server, contracts, docs, common, dependencies, github, config, or repo), and message is a short lowercase description

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: All commits must start with a single gitmoji from the official gitmoji list; this is not optional and the emoji visually communicates the intent of the change

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/.changeset/*.md : Use a lowercase sentence in the imperative present tense for changeset summaries

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Enforce Node.js best practices using ESLint `plugin:n/recommended` configuration

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/api/**/*.ts : Never instantiate or directly access a database client from within a route handler; it must be provided via context

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Do not use abbreviations or cryptic names; write out full words like `error`, `parameters`, `request` instead of `err`, `params`, `req`

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All code comments must be lowercase; special tags (TODO, FIXME) are uppercase followed by a single space and lowercase comment, without colons or dashes, and should include a ticket/issue reference when available

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:22.339Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/markdown.mdc:0-0
Timestamp: 2025-12-23T19:57:22.339Z
Learning: Applies to **/*.md : All code comments must be lowercase

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Prefer self-documenting code; avoid comments explaining 'what' the code does; comments should explain 'why' code is written a certain way

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/queues/alchemyQueue.ts
  • server/utils/createCredential.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx} : Use PascalCase for TypeScript types and interfaces

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Use Hono's built-in error handling by throwing `new HTTPException()` for expected errors; unhandled errors will be caught and logged automatically

Applied to files:

  • server/utils/createCredential.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/package.json
  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:56:56.405Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/dev.mdc:0-0
Timestamp: 2025-12-23T19:56:56.405Z
Learning: Server (exactly/server) uses Hono (framework), Node.js, Drizzle ORM (database), and PostgreSQL

Applied to files:

  • server/package.json
📚 Learning: 2026-01-15T19:10:07.248Z
Learnt from: mainqueg
Repo: exactly/exa PR: 637
File: server/utils/persona.ts:155-160
Timestamp: 2026-01-15T19:10:07.248Z
Learning: In server/utils/persona.ts, the PERSONA_API_VERSION constant is intentionally set to "2023-01-05" to match the API version configured for the production API key in Persona's admin dashboard. This ensures consistent response behavior across different environments and should not be updated without also updating the production API key configuration.

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
🧬 Code graph analysis (5)
server/index.ts (1)
server/queues/alchemyQueue.ts (1)
  • alchemyWorker (67-67)
server/test/utils/createCredential.test.ts (2)
server/utils/createCredential.ts (1)
  • createCredential (24-68)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/queues/alchemyQueue.test.ts (3)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (2)
  • AlchemyJobData (15-20)
  • processor (38-65)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
server/utils/createCredential.ts (5)
server/test/utils/createCredential.test.ts (1)
  • webhookId (46-48)
server/hooks/activity.ts (1)
  • webhookId (48-48)
server/queues/alchemyQueue.ts (1)
  • alchemyQueue (30-30)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/test/e2e.ts (1)
  • captureException (58-61)
🔇 Additional comments (10)
server/script/openapi.ts (1)

28-29: LGTM!

The REDIS_URL now uses proper URL format for local development, and DISABLE_WORKERS="true" correctly prevents worker initialization during OpenAPI spec generation. Both changes align with the new queue infrastructure.

server/index.ts (2)

18-18: LGTM!

Import correctly added for the new queue worker.


288-293: LGTM!

The shutdown sequence correctly includes alchemyWorker?.close() with proper handling for when the worker is undefined. Using Promise.allSettled ensures all cleanup tasks are attempted even if some fail.

.changeset/short-cars-return.md (1)

1-5: LGTM!

Changeset follows the required format with gitmoji prefix and lowercase imperative message. Patch level is appropriate for this feature addition.

server/test/utils/pax.test.ts (3)

10-10: LGTM!

Using globalThis instead of global is the correct ECMAScript standard for accessing the global object, improving cross-environment consistency.


66-66: Consistent with the beforeEach mock.


101-101: Consistent with the beforeEach mock.

server/queues/constants.ts (1)

1-11: Centralized queue/job constants look good.
Clear single source of truth for queue/job names.

server/utils/createCredential.ts (1)

6-22: Queue-based enqueue + contextual error capture looks solid.

Also applies to: 55-61

server/queues/alchemyQueue.ts (1)

38-61: Fail-fast processor behavior is good.
Explicitly throwing on non-OK API responses and unknown job names prevents silent failures.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

import { type AlchemyJobData, processor } from "../../queues/alchemyQueue";
import { AlchemyJob } from "../../queues/constants";

// Mock dependencies
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use lowercase comment text to match the style guide.
As per coding guidelines.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Mock dependencies
// mock dependencies
🤖 Prompt for AI Agents
In `@server/test/queues/alchemyQueue.test.ts` at line 8, Change the comment "//
Mock dependencies" to lowercase to follow the style guide: replace it with "mock
dependencies" in the alchemyQueue.test.ts file (look for the top-of-file comment
string "// Mock dependencies") so the test file's comment text uses lowercase
styling.

addJob: vi.fn().mockResolvedValue({}),
}));

// Mock dependencies
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use lowercase comment text to match the style guide.
As per coding guidelines.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies
-// Mock global fetch to avoid actual network calls
+// mock global fetch to avoid actual network calls

Also applies to: 55-55

🤖 Prompt for AI Agents
In `@server/test/utils/createCredential.test.ts` at line 13, Replace the comment
string "// Mock dependencies" with a lowercase version "// mock dependencies"
wherever it appears in the test (both occurrences flagged in the review) so the
comment text matches the project's style guide; search for the exact comment
token and update it to the lowercase form.

@aguxez aguxez force-pushed the feature/webhook-queue branch from 222172e to 76d5baa Compare January 16, 2026 16:56
Copy link

@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

🤖 Fix all issues with AI agents
In `@server/script/openapi.ts`:
- Around line 28-29: Replace the direct assignments to process.env.REDIS_URL and
process.env.DISABLE_WORKERS in server/script/openapi.ts by reading those values
from the centralized configuration/bootstrap and passing them into the OpenAPI
script via dependency injection or a specific OpenAPI script config override;
remove the two lines setting process.env.REDIS_URL and
process.env.DISABLE_WORKERS, add parameters or a config object (sourced from
your existing bootstrap/config module) to the OpenAPI entry point so the script
uses config.REDIS_URL and config.DISABLE_WORKERS (or equivalent) instead of
mutating process.env directly.
♻️ Duplicate comments (6)
server/test/queues/alchemyQueue.test.ts (2)

8-8: Use lowercase comment text.

Per coding guidelines, all code comments must be lowercase.

-// Mock dependencies
+// mock dependencies

53-53: Remove unnecessary type assertion.

The as Record<string, string> cast is redundant—expect.objectContaining() handles matcher types correctly in Vitest.

♻️ Proposed fix
-        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) as Record<string, string>,
+        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }),
server/test/utils/createCredential.test.ts (3)

13-13: Use lowercase comment text.

Per coding guidelines, all code comments must be lowercase.

-// Mock dependencies
+// mock dependencies
-// Mock global fetch to avoid actual network calls
+// mock global fetch to avoid actual network calls

Also applies to: 55-55


78-78: Remove unnecessary type assertion.

The as string cast is redundant—expect.stringMatching() returns the correct matcher type for Vitest.

♻️ Proposed fix
-        account: expect.stringMatching(/^0x/) as string,
+        account: expect.stringMatching(/^0x/),

98-98: Remove unnecessary type assertion.

The as Record<string, unknown> cast is redundant.

♻️ Proposed fix
-        }) as Record<string, unknown>,
+        }),
server/queues/alchemyQueue.ts (1)

9-9: Direct process.env access violates coding guidelines.

Per guidelines: "Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context."

Both DISABLE_WORKERS and REDIS_URL should be loaded from a centralized configuration module. Based on learnings, configuration should be loaded once at startup.

Also applies to: 22-23

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 222172e and 76d5baa.

📒 Files selected for processing (9)
  • .changeset/short-cars-return.md
  • server/index.ts
  • server/queues/alchemyQueue.ts
  • server/queues/constants.ts
  • server/script/openapi.ts
  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/.changeset/*.md

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

Use a lowercase sentence in the imperative present tense for changeset summaries

Files:

  • .changeset/short-cars-return.md
server/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/server.mdc)

server/**/*.ts: Use c.var object to pass strongly-typed data between Hono middleware and route handlers; do not use c.set
All request validation (headers, body, params) must be handled by @hono/valibot-validator middleware; do not perform manual validation inside route handlers
Use Hono's built-in error handling by throwing new HTTPException() for expected errors; unhandled errors will be caught and logged automatically
Enforce Node.js best practices using ESLint plugin:n/recommended configuration
Enforce Drizzle ORM best practices using ESLint plugin:drizzle/all configuration, including requiring where clauses for update and delete operations
Use Drizzle ORM query builder for all database interactions; do not write raw SQL queries unless absolutely unavoidable
All authentication and authorization logic must be implemented in Hono middleware
Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context
Avoid long-running, synchronous operations; use async/await correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.{js,ts,tsx,jsx,sol}

📄 CodeRabbit inference engine (AGENTS.md)

Follow linter/formatter (eslint, prettier, solhint) strictly with high strictness level. No any type.

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Omit redundant type names in variable declarations - let the type system explain itself

**/*.{ts,tsx}: Use PascalCase for TypeScript types and interfaces
Use valibot for all runtime validation of API inputs, environment variables, and other data; define schemas once and reuse them
Infer TypeScript types from valibot schemas using type User = v.Input<typeof UserSchema> instead of manually defining interfaces

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Omit contextual names - don't repeat class/module names in members
Omit meaningless words like 'data', 'state', 'manager', 'engine', 'value' from variable and function names unless they add disambiguation

**/*.{ts,tsx,js,jsx}: Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations
Prefer const for all variable declarations by default; only use let if the variable's value will be reassigned
Declare each variable on its own line with its own const or let keyword, not multiple declarations on one line
Use camelCase for TypeScript variables and functions
Always use import type { ... } for type imports
Use relative paths for all imports within the project; avoid tsconfig path aliases
Follow eslint-plugin-import order: react, external libraries, then relative paths
Use object and array destructuring to access and use properties
Use object method shorthand syntax when a function is a property of an object
Prefer optional chaining (?.), nullish coalescing (??), object and array spreading (...), and for...of loops over traditional syntax
Do not use abbreviations or cryptic names; write out full words like error, parameters, request instead of err, params, req
Use Number.parseInt() instead of the global parseInt() function when parsing numbers
All classes called with new must use PascalCase
Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead of the deprecated new Buffer()
Use @ts-expect-error instead of @ts-ignore; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like - or :
Do not include the type in a variable's name; let the static type system do its job (e.g., use const user: User not const userObject: User)
Do not repeat the name of a class or module within its members; omit contextual names (e.g., use `class User { getProfil...

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

server/**/*.{ts,tsx}: Server API: implement schema-first approach using OpenAPI via hono with validation via valibot middleware
Server database: drizzle schema is source of truth. Migrations required. No direct database access in handlers - use c.var.db

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/style.mdc)

For files with a single default export, name the file identically to the export; for files with multiple exports, use camelCase with a strong preference for a single word

Files:

  • server/test/queues/alchemyQueue.test.ts
  • server/queues/constants.ts
  • server/index.ts
  • server/test/utils/createCredential.test.ts
  • server/test/utils/pax.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
🧠 Learnings (23)
📚 Learning: 2025-12-31T00:23:55.034Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 610
File: .changeset/ready-experts-fly.md:1-2
Timestamp: 2025-12-31T00:23:55.034Z
Learning: In the exactly/exa repository, allow and require empty changeset files (containing only --- separators) when changes are not user-facing and do not warrant a version bump. This is needed because CI runs changeset status --since origin/main and requires a changeset file to exist. Ensure such empty changesets are used only for non-user-facing changes and document the rationale in the commit or changelog notes.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2026-01-09T16:24:11.460Z
Learnt from: cruzdanilo
Repo: exactly/exa PR: 627
File: .changeset/breezy-planes-repeat.md:5-5
Timestamp: 2026-01-09T16:24:11.460Z
Learning: In the exactly/exa repository, changeset summaries in .changeset/*.md must start with a gitmoji and follow the format '<emoji> <message>' (no scope). This should mirror the commit message format '<emoji> <scope>: <message>' but omit the '<scope>:' portion. Ensure the message is clear and describes the change.

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: Select the most precise gitmoji that best communicates the intent of the change (e.g., ✨ for new feature, 🐛 for bug fix, ♻️ for refactoring, ⚡️ for performance improvement, 📝 for documentation, 🚀 for deployment)

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Use gitmoji format for commits: `<emoji> <scope>: <message>` with scopes: `app`, `server`, `contracts`, `common`, `docs`

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: All commit messages must strictly adhere to the format: `<emoji> <scope>: <message>` where emoji is a gitmoji unicode character, scope is a mandatory short name (app, server, contracts, docs, common, dependencies, github, config, or repo), and message is a short lowercase description

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:14.465Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-12-23T19:57:14.465Z
Learning: All commits must start with a single gitmoji from the official gitmoji list; this is not optional and the emoji visually communicates the intent of the change

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/.changeset/*.md : Use a lowercase sentence in the imperative present tense for changeset summaries

Applied to files:

  • .changeset/short-cars-return.md
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Do not access `process.env` directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context

Applied to files:

  • server/test/queues/alchemyQueue.test.ts
  • server/index.ts
  • server/queues/alchemyQueue.ts
  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Avoid long-running, synchronous operations; use `async/await` correctly and be mindful of CPU-intensive tasks to prevent blocking the event loop

Applied to files:

  • server/test/queues/alchemyQueue.test.ts
  • server/index.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All code comments must be lowercase; special tags (TODO, FIXME) are uppercase followed by a single space and lowercase comment, without colons or dashes, and should include a ticket/issue reference when available

Applied to files:

  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:22.339Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/markdown.mdc:0-0
Timestamp: 2025-12-23T19:57:22.339Z
Learning: Applies to **/*.md : All code comments must be lowercase

Applied to files:

  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `ts-expect-error` instead of `ts-ignore`; follow it immediately with a single-line lowercase comment explaining why the error is expected, without separators like `-` or `:`

Applied to files:

  • server/test/queues/alchemyQueue.test.ts
  • server/test/utils/createCredential.test.ts
  • server/utils/createCredential.ts
  • server/queues/alchemyQueue.ts
📚 Learning: 2026-01-15T19:06:40.947Z
Learnt from: mainqueg
Repo: exactly/exa PR: 637
File: server/hooks/persona.ts:186-195
Timestamp: 2026-01-15T19:06:40.947Z
Learning: In server/hooks/persona.ts, the webhook handler has intentionally different error handling for Manteca vs Panda flows: the Manteca path (payload.template === "manteca") lets addDocument errors propagate to enable webhook retries, while the Panda path uses .catch() to swallow addDocument errors and prevent retries since the user creation is already committed.

Applied to files:

  • server/index.ts
  • server/utils/createCredential.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Use Hono's built-in error handling by throwing `new HTTPException()` for expected errors; unhandled errors will be caught and logged automatically

Applied to files:

  • server/utils/createCredential.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/**/*.ts : Enforce Node.js best practices using ESLint `plugin:n/recommended` configuration

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-23T19:57:35.503Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/server.mdc:0-0
Timestamp: 2025-12-23T19:57:35.503Z
Learning: Applies to server/api/**/*.ts : Never instantiate or directly access a database client from within a route handler; it must be provided via context

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Do not use abbreviations or cryptic names; write out full words like `error`, `parameters`, `request` instead of `err`, `params`, `req`

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Prefer self-documenting code; avoid comments explaining 'what' the code does; comments should explain 'why' code is written a certain way

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx} : Use PascalCase for TypeScript types and interfaces

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2025-12-30T15:03:28.449Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: .cursor/rules/style.mdc:0-0
Timestamp: 2025-12-30T15:03:28.449Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Prefer function declarations for all multi-line functions; use function expressions or arrow functions only for single-line implementations

Applied to files:

  • server/queues/alchemyQueue.ts
📚 Learning: 2026-01-15T19:10:07.248Z
Learnt from: mainqueg
Repo: exactly/exa PR: 637
File: server/utils/persona.ts:155-160
Timestamp: 2026-01-15T19:10:07.248Z
Learning: In server/utils/persona.ts, the PERSONA_API_VERSION constant is intentionally set to "2023-01-05" to match the API version configured for the production API key in Persona's admin dashboard. This ensures consistent response behavior across different environments and should not be updated without also updating the production API key configuration.

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Zero config local dev environment: no `.env` files, mock all external services

Applied to files:

  • server/script/openapi.ts
📚 Learning: 2025-12-23T19:58:16.574Z
Learnt from: CR
Repo: exactly/exa PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-23T19:58:16.574Z
Learning: Server stack: use hono, node.js, drizzle orm, postgres

Applied to files:

  • server/script/openapi.ts
🧬 Code graph analysis (3)
server/index.ts (1)
server/queues/alchemyQueue.ts (1)
  • alchemyWorker (67-67)
server/test/utils/createCredential.test.ts (3)
.maestro/maestro.d.ts (1)
  • Response (19-19)
server/utils/createCredential.ts (1)
  • createCredential (24-68)
server/queues/constants.ts (1)
  • AlchemyJob (7-9)
server/queues/alchemyQueue.ts (1)
server/queues/constants.ts (2)
  • QueueName (1-3)
  • AlchemyJob (7-9)
🪛 GitHub Actions: test
server/queues/alchemyQueue.ts

[error] 30-30: Type 'Redis' is not assignable to type 'ConnectionOptions'. (TS2322) during 'nx run @exactly/mobile:"test:ts"' (tsc)

🪛 GitHub Check: test
server/queues/alchemyQueue.ts

[failure] 73-73:
Type 'Redis' is not assignable to type 'ConnectionOptions'.


[failure] 30-30:
Type 'Redis' is not assignable to type 'ConnectionOptions'.

🔇 Additional comments (10)
.changeset/short-cars-return.md (1)

1-5: LGTM.

Changeset format and summary look good.

server/index.ts (1)

18-18: Worker shutdown is correctly wired into the close path.

The optional close with a safe fallback is a solid addition to graceful shutdown.

Also applies to: 288-293

server/test/utils/pax.test.ts (1)

10-10: Switching to globalThis.fetch in tests looks good.

Also applies to: 66-66, 101-101

server/queues/constants.ts (1)

1-11: LGTM — clear, typed queue/job constants.

server/test/queues/alchemyQueue.test.ts (1)

33-89: LGTM! Good test coverage for the processor.

The test suite covers the critical paths:

  • Successful ADD_SUBSCRIBER job with correct API call verification
  • Error throwing for unknown job names
  • Error handling when Alchemy API fails
server/utils/createCredential.ts (1)

55-61: LGTM! Queue integration with proper guards.

The implementation correctly:

  • Guards against undefined webhookId with a ternary
  • Enqueues the job asynchronously without blocking credential creation
  • Captures exceptions with rich context (level, job type, account, webhookId)
server/test/utils/createCredential.test.ts (1)

103-111: LGTM! Good edge case coverage.

This test correctly verifies that when webhookId is undefined:

  • No job is added to the queue
  • No exception is captured

This aligns with the guarded behavior in createCredential.ts.

server/queues/alchemyQueue.ts (3)

71-101: LGTM! Worker lifecycle and error handling.

The worker implementation correctly:

  • Guards initialization with DISABLE_WORKERS flag
  • Stores the worker reference for graceful shutdown
  • Includes rate limiting (limiter: { max: 10, duration: 1000 })
  • Handles all essential events: failed, completed, active, error
  • Captures exceptions and breadcrumbs for observability

38-65: LGTM! Processor implementation with proper error handling.

The processor correctly:

  • Wraps execution in Sentry spans for tracing
  • Handles the ADD_SUBSCRIBER job type
  • Throws on unknown job names (fail-fast pattern)
  • Propagates API errors with status and response text

22-30: Remove incorrect type error claim; address direct process.env access instead.

The code correctly passes an ioredis instance to BullMQ's Queue constructor. BullMQ v5 explicitly accepts ioredis instances as the connection parameter, and maxRetriesPerRequest: null is a required setting for BullMQ worker clients. The proposed type fix is invalid and based on a misunderstanding of BullMQ's API.

The actual issue is direct process.env access at lines 9 and 22, which violates the coding guideline: "Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context." Move these to a centralized configuration module loaded at startup.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

server/index.ts Outdated
Comment on lines 290 to 295
Promise.allSettled([
closeSentry(),
closeSegment(),
database.$client.end(),
alchemyWorker?.close() ?? Promise.resolve(),
])

This comment was marked as outdated.

Copy link

@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

🤖 Fix all issues with AI agents
In `@server/utils/createCredential.ts`:
- Around line 55-61: Update the test mock and imports so they match the
production usage of Sentry: in the test file createCredential.test.ts replace
the import of captureException from "@sentry/node" with an import from
"@sentry/core" and expand the vi.mock for "@sentry/core" to export both setUser
and captureException (e.g., setUser: vi.fn(), captureException: vi.fn()) so the
production call to captureException in createCredential.ts is properly stubbed
during tests.
♻️ Duplicate comments (8)
server/script/openapi.ts (1)

28-29: Avoid mutating process.env in this script; use centralized config/DI.
New env assignments should come from the existing config bootstrap and be passed into the OpenAPI generator rather than mutating globals here. Based on learnings, this should be moved out of server/**/*.ts application code.

server/test/utils/createCredential.test.ts (3)

13-13: Lowercase comment text to match style rules.
As per coding guidelines.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies
...
-// Mock global fetch to avoid actual network calls
+// mock global fetch to avoid actual network calls

Also applies to: 55-55


78-78: Drop redundant as string in matcher.
expect.stringMatching() already yields a compatible matcher type.

♻️ Proposed fix
-        account: expect.stringMatching(/^0x/) as string,
+        account: expect.stringMatching(/^0x/),

98-98: Remove unnecessary Record<string, unknown> cast.
The matcher type is sufficient without the assertion.

♻️ Proposed fix
-        }) as Record<string, unknown>,
+        }),
server/test/queues/alchemyQueue.test.ts (3)

1-6: Prevent Redis connections during tests.
Importing alchemyQueue at module load can create a Worker and attempt Redis connections (matches the EAI_AGAIN redis failure). Set DISABLE_WORKERS before the module is evaluated (e.g., in a Vitest setup file) or mock the BullMQ Worker so no real Redis connection is attempted.

Run this to confirm whether DISABLE_WORKERS is already set anywhere in test setup:

#!/bin/bash
rg -n "DISABLE_WORKERS"

8-8: Lowercase comment text to match style rules.
As per coding guidelines.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies

53-53: Remove redundant header type assertion.
expect.objectContaining() already handles the matcher type.

♻️ Proposed fix
-        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) as Record<string, string>,
+        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }),
server/queues/alchemyQueue.ts (1)

9-10: Direct process.env access violates coding guidelines.

Lines 9 and 22-23 directly access process.env.DISABLE_WORKERS and process.env.REDIS_URL. Per coding guidelines: "Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context."

Additionally, the magic number 2 for SENTRY_SPAN_ERROR_CODE should be documented.

♻️ Suggested improvements
-const SENTRY_SPAN_ERROR_CODE = 2;
+// opentelemetry status code for error (see https://opentelemetry.io/docs/specs/otel/trace/api/#set-status)
+const SENTRY_SPAN_ERROR_CODE = 2;

For the process.env access, consider creating a factory function that accepts configuration:

interface AlchemyQueueConfig {
  disableWorkers: boolean;
  redisUrl: string;
}

export function initializeAlchemyQueue(config: AlchemyQueueConfig) {
  const connection = new Redis(config.redisUrl, { maxRetriesPerRequest: null });
  // ... rest of initialization
}

@aguxez aguxez force-pushed the feature/webhook-queue branch from b7b66fc to dbc2973 Compare January 19, 2026 16:49
Copy link

@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

🤖 Fix all issues with AI agents
In `@server/utils/createCredential.ts`:
- Around line 55-61: The current conditional in createCredential.ts skips
enqueuing AlchemyJob.ADD_SUBSCRIBER when the module-level webhookId is still
undefined (set asynchronously in activity.ts), causing missed subscriptions
during startup; modify createCredential logic so that when webhookId is
undefined it does not silently drop the job but instead either (A) persist a
pending-subscription record (e.g., push the credential id/account into a
temporary pending list or DB table) and expose a function like
processPendingAlchemySubscriptions() that activity.ts calls once webhookId is
initialized to enqueue AlchemyJob.ADD_SUBSCRIBER for each pending item, or (B)
throw a retriable error to defer credential creation until webhookId is ready;
implement with references to webhookId,
alchemyQueue.add(AlchemyJob.ADD_SUBSCRIBER,...), and activity.ts initialization
to ensure missed ADD_SUBSCRIBER jobs are reconciled after webhookId is set.
♻️ Duplicate comments (8)
server/queues/alchemyQueue.ts (2)

22-23: Direct process.env.REDIS_URL access.

This violates the coding guideline: "Do not access process.env directly in application code." The Redis connection configuration should be loaded from a centralized config module at startup. This was flagged in previous reviews.


9-10: Direct process.env access and magic number.

  1. process.env.DISABLE_WORKERS violates the guideline to load configuration at startup and pass via DI/context.
  2. The value 2 for SENTRY_SPAN_ERROR_CODE is an OpenTelemetry STATUS_CODE_ERROR. Consider adding a comment or importing from @opentelemetry/api for clarity.
📚 Proposed documentation fix for magic number
 const disableWorkers = process.env.DISABLE_WORKERS === "true";
-const SENTRY_SPAN_ERROR_CODE = 2;
+// opentelemetry status code for error (see https://opentelemetry.io/docs/specs/otel/trace/api/#set-status)
+const SENTRY_SPAN_ERROR_CODE = 2;
server/script/openapi.ts (1)

28-29: Direct process.env mutations extend env mutation pattern.

These new assignments continue the pattern of direct env mutation. As flagged in a previous review, consider moving these values into centralized config bootstrap. However, this is a script file for OpenAPI generation, so the impact is limited to build-time tooling.

server/test/queues/alchemyQueue.test.ts (2)

53-53: Remove unnecessary type assertion.

The as Record<string, string> cast is redundant—expect.objectContaining() handles matcher types correctly in Vitest.

♻️ Proposed fix
-        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) as Record<string, string>,
+        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }),

8-8: Use lowercase comment text.

Per coding guidelines, all code comments must be lowercase.

✍️ Proposed fix
-// Mock dependencies
+// mock dependencies
server/test/utils/createCredential.test.ts (3)

14-14: Use lowercase comment text per style guide.

Comments should be lowercase as per coding guidelines.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies
-// Mock global fetch to avoid actual network calls
+// mock global fetch to avoid actual network calls

Also applies to: 57-57


80-80: Remove unnecessary type assertion.

The as string cast is redundant—expect.stringMatching() returns the correct matcher type for Vitest.

♻️ Proposed fix
-        account: expect.stringMatching(/^0x/) as string,
+        account: expect.stringMatching(/^0x/),

97-100: Remove the unnecessary type assertion.

The as Record<string, unknown> cast is redundant—the matcher type is sufficient.

♻️ Proposed fix
         extra: expect.objectContaining({
           job: AlchemyJob.ADD_SUBSCRIBER,
           webhookId: "webhook-id",
-        }) as Record<string, unknown>,
+        }),

Comment on lines +55 to +63
webhookId
? alchemyQueue
.add(AlchemyJob.ADD_SUBSCRIBER, { account, webhookId })
.catch((error: unknown) =>
captureException(error, { level: "error", extra: { job: AlchemyJob.ADD_SUBSCRIBER, account, webhookId } }),
)
: undefined,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there's any retry or reconciliation logic for missed webhook subscriptions
echo "=== Checking for retry/reconciliation mechanisms ==="
rg -n -B 2 -A 5 "webhookId|ADD_SUBSCRIBER" server/queues/ server/hooks/activity.ts 2>/dev/null || echo "(No matches or files not found)"

echo -e "\n=== Check if webhookId is ever retried or reconciled ==="
rg -n "retry|reconcile|missing.*webhook|sync.*subscriber" server/ 2>/dev/null || echo "(No matches)"

echo -e "\n=== Check createCredential.ts context around webhookId handling ==="
cat -n server/utils/createCredential.ts 2>/dev/null | head -80

Repository: exactly/exa

Length of output: 7191


Conditional guard prevents errors, but silent skip during startup race causes missed subscriptions.

The webhookId check properly prevents queuing jobs with undefined IDs and error handling includes useful context. However, verification reveals a critical gap: webhookId is a module-level variable initialized asynchronously in activity.ts (lines 248–252). Credentials created during server startup—before the webhook is fetched/created—will silently skip enqueuing ADD_SUBSCRIBER jobs. Unlike early failures after webhookId is set, these early subscriptions have no recovery mechanism.

No retry or reconciliation logic exists to handle missed subscriptions. Consider:

  • Retrying ADD_SUBSCRIBER for credentials created before webhookId initialization completes
  • Or deferring credential creation until webhook is ready
🤖 Prompt for AI Agents
In `@server/utils/createCredential.ts` around lines 55 - 61, The current
conditional in createCredential.ts skips enqueuing AlchemyJob.ADD_SUBSCRIBER
when the module-level webhookId is still undefined (set asynchronously in
activity.ts), causing missed subscriptions during startup; modify
createCredential logic so that when webhookId is undefined it does not silently
drop the job but instead either (A) persist a pending-subscription record (e.g.,
push the credential id/account into a temporary pending list or DB table) and
expose a function like processPendingAlchemySubscriptions() that activity.ts
calls once webhookId is initialized to enqueue AlchemyJob.ADD_SUBSCRIBER for
each pending item, or (B) throw a retriable error to defer credential creation
until webhookId is ready; implement with references to webhookId,
alchemyQueue.add(AlchemyJob.ADD_SUBSCRIBER,...), and activity.ts initialization
to ensure missed ADD_SUBSCRIBER jobs are reconciled after webhookId is set.

@aguxez aguxez force-pushed the feature/webhook-queue branch 2 times, most recently from b958bf1 to fe883d0 Compare January 22, 2026 14:37
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View issue and 7 additional flags in Devin Review.

Open in Devin Review

}

export async function close() {
await Promise.all([connection.quit(), alchemyWorker?.close() ?? Promise.resolve(), alchemyQueue.close()]);

Choose a reason for hiding this comment

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

🔴 Redis connection closed in parallel with Queue and Worker, causing improper shutdown

In the close() function at server/queues/alchemyQueue.ts:105, the Redis connection is quit in parallel with closing the BullMQ Worker and Queue:

await Promise.all([connection.quit(), alchemyWorker?.close() ?? Promise.resolve(), alchemyQueue.close()]);

BullMQ's Worker.close() and Queue.close() methods require an active Redis connection to properly clean up resources (release locks, update job states, etc.). By calling connection.quit() in parallel, the connection may be terminated before the Worker and Queue finish their cleanup process.

Actual behavior: The Redis connection could close before the Worker/Queue finish cleanup, causing errors or incomplete shutdown.

Expected behavior: The Worker and Queue should be closed first, then the Redis connection should be quit.

Impact: During graceful shutdown (SIGINT/SIGTERM), jobs being processed may not complete properly, the worker may not release its lock on active jobs, and errors may be thrown when the Worker/Queue try to communicate with an already-closed Redis connection.

Recommendation: Close the Worker and Queue first, then quit the Redis connection:

export async function close() {
  await Promise.all([alchemyWorker?.close() ?? Promise.resolve(), alchemyQueue.close()]);
  await connection.quit();
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +104 to +106
export async function close() {
await Promise.all([connection.quit(), alchemyWorker?.close() ?? Promise.resolve(), alchemyQueue.close()]);
}

This comment was marked as outdated.

@aguxez aguxez force-pushed the feature/webhook-queue branch from 3d4a2fe to 838c475 Compare January 23, 2026 20:09
Copy link

@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

🤖 Fix all issues with AI agents
In `@server/test/queues/alchemyQueue.test.ts`:
- Around line 1-7: Add the Redis mock import at the top of the test module to
prevent real Redis connection during module initialization: insert an import
statement for the test Redis mock (e.g., import "../mocks/redis";) as the very
first import in alchemyQueue.test.ts so it runs before importing the module that
instantiates Redis (the module that exports processor and
AlchemyJob/AlchemyJobData from ../../queues/alchemyQueue), ensuring ioredis-mock
is used during tests.
♻️ Duplicate comments (11)
server/script/openapi.ts (1)

28-29: Environment variable additions follow existing pattern in this CLI script.

These new process.env assignments are consistent with the existing pattern in this OpenAPI generation script (lines 7-27). While the coding guidelines discourage direct process.env access in application code, CLI scripts that bootstrap test/generation environments are a common exception. The DISABLE_WORKERS="true" correctly prevents worker instantiation during spec generation.

server/test/utils/createCredential.test.ts (4)

14-14: Use lowercase comment text.

As per coding guidelines, all code comments must be lowercase.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies

57-57: Use lowercase comment text.

As per coding guidelines.

♻️ Proposed fix
-// Mock global fetch to avoid actual network calls
+// mock global fetch to avoid actual network calls

80-80: Remove unnecessary type assertion.

The as string cast is redundant—expect.stringMatching() returns the correct matcher type.

♻️ Proposed fix
-        account: expect.stringMatching(/^0x/) as string,
+        account: expect.stringMatching(/^0x/),

97-100: Remove unnecessary type assertion.

The as Record<string, unknown> cast is redundant—expect.objectContaining() handles matcher types correctly.

♻️ Proposed fix
         extra: expect.objectContaining({
           job: AlchemyJob.ADD_SUBSCRIBER,
           webhookId: "webhook-id",
-        }) as Record<string, unknown>,
+        }),
server/test/queues/alchemyQueue.test.ts (2)

9-9: Use lowercase comment text.

As per coding guidelines, all code comments must be lowercase.

♻️ Proposed fix
-// Mock dependencies
+// mock dependencies

54-54: Remove unnecessary type assertion.

The as Record<string, string> cast is redundant—expect.objectContaining() handles matcher types correctly.

♻️ Proposed fix
-        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }) as Record<string, string>,
+        headers: expect.objectContaining({ "X-Alchemy-Token": "mock-token" }),
server/utils/createCredential.ts (1)

57-63: Conditional guard is correct but silent skip during startup race remains a concern.

The implementation properly guards against undefined webhookId and includes comprehensive error context (level: "error", extra: { job, account, webhookId }). However, credentials created before webhookId initialization completes will silently skip the ADD_SUBSCRIBER job with no recovery mechanism.

Consider logging when webhookId is undefined so missed subscriptions are observable:

🔍 Suggested observability improvement
     webhookId
       ? alchemyQueue
           .add(AlchemyJob.ADD_SUBSCRIBER, { account, webhookId })
           .catch((error: unknown) =>
             captureException(error, { level: "error", extra: { job: AlchemyJob.ADD_SUBSCRIBER, account, webhookId } }),
           )
-      : undefined,
+      : captureException(new Error("webhookId not initialized"), {
+          level: "warning",
+          extra: { account },
+        }),
server/queues/alchemyQueue.ts (3)

8-10: Direct process.env access violates coding guidelines.

Per guidelines: "Do not access process.env directly in application code; load all configuration and secrets once at startup and pass them through dependency injection or context."

The DISABLE_WORKERS flag should be loaded at startup and injected.


104-106: Parallel shutdown creates a race condition.

BullMQ requires sequential shutdown: worker first, then queue, then Redis connection. The current Promise.all approach may terminate the Redis connection before Worker/Queue finish their cleanup (releasing locks, updating job states).

🐛 Proposed fix for sequential shutdown
 export async function close() {
-  await Promise.all([connection.quit(), alchemyWorker?.close() ?? Promise.resolve(), alchemyQueue.close()]);
+  await alchemyWorker?.close();
+  await alchemyQueue.close();
+  await connection.quit();
 }

22-23: Load REDIS_URL at startup and pass through dependency injection, not process.env directly.

Lines 22-23 directly access process.env.REDIS_URL, which violates the guideline to load configuration and secrets once at startup and pass them through dependency injection or context. The same issue exists on line 9 with process.env.DISABLE_WORKERS. Move environment variable loading to a configuration module initialized at startup, then inject the connection or URL into the queue setup.

Comment on lines +1 to +7
import { startSpan } from "@sentry/node";
import { beforeEach, describe, expect, it, vi } from "vitest";

import { processor, type AlchemyJobData } from "../../queues/alchemyQueue";
import { AlchemyJob } from "../../queues/constants";

import type { Job } from "bullmq";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if DISABLE_WORKERS is set in vitest setup or config files
echo "=== Checking vitest config for DISABLE_WORKERS ==="
fd -e ts -e js "vitest" --exec grep -l "DISABLE_WORKERS" {} 2>/dev/null || echo "Not found in vitest files"

echo ""
echo "=== Checking server test setup files ==="
fd "setup" server/test --exec cat {} 2>/dev/null || echo "No setup files found"

echo ""
echo "=== Checking alchemyQueue module for DISABLE_WORKERS usage ==="
cat server/queues/alchemyQueue.ts 2>/dev/null | head -80

Repository: exactly/exa

Length of output: 3051


🏁 Script executed:

#!/bin/bash
# Check the actual test file
echo "=== Test file content ==="
cat -n server/test/queues/alchemyQueue.test.ts 2>/dev/null | head -40

echo ""
echo "=== Looking for vitest.config files ==="
fd "vitest.config" . -type f

echo ""
echo "=== Looking for vitest config in package.json or root ==="
find . -maxdepth 2 -name "*.config.*" -o -name "vitest.config.*" | grep -v node_modules

echo ""
echo "=== Checking if there's a setup file referenced ==="
find . -maxdepth 3 -name "*setup*" -type f | grep -v node_modules | head -10

Repository: exactly/exa

Length of output: 2332


🏁 Script executed:

#!/bin/bash
# Check the vitest.config.mts file
echo "=== Server vitest config ==="
cat -n server/vitest.config.mts

echo ""
echo "=== Check for REDIS_URL handling in vitest config ==="
grep -A 5 -B 5 "REDIS_URL\|DISABLE_WORKERS\|setup" server/vitest.config.mts || echo "Not found in config"

Repository: exactly/exa

Length of output: 2675


🏁 Script executed:

#!/bin/bash
# Check global setup files for DISABLE_WORKERS handling
echo "=== Checking test/anvil.ts ==="
head -30 server/test/anvil.ts 2>/dev/null

echo ""
echo "=== Checking test/database.ts ==="
head -30 server/test/database.ts 2>/dev/null

echo ""
echo "=== Checking test/spotlight.ts ==="
head -30 server/test/spotlight.ts 2>/dev/null

echo ""
echo "=== Checking if Redis is mocked in tests ==="
fd "redis" server/test --type f -x cat {} 2>/dev/null | head -50

Repository: exactly/exa

Length of output: 3195


🏁 Script executed:

#!/bin/bash
# Find where the Redis mock is defined
echo "=== Finding Redis mock file ==="
fd -t f "redis" server/test -exec head -5 {} + 2>/dev/null | head -20

echo ""
echo "=== Checking all files in server/test for vi.mock ==="
rg "vi\.mock.*redis" server/test -B 2 -A 2

echo ""
echo "=== Looking for the complete Redis mock setup ==="
fd -t f . server/test -exec grep -l "ioredis-mock" {} \; 2>/dev/null

Repository: exactly/exa

Length of output: 926


🏁 Script executed:

#!/bin/bash
# Check the complete Redis mock file
echo "=== Complete Redis mock file ==="
cat -n server/test/mocks/redis.ts

echo ""
echo "=== Check if alchemyQueue.test.ts imports redis mock ==="
grep -n "redis\|mock" server/test/queues/alchemyQueue.test.ts | head -20

echo ""
echo "=== Check for vitest setup in alchemyQueue.test.ts ==="
grep -n "import\|DISABLE_WORKERS" server/test/queues/alchemyQueue.test.ts | head -20

Repository: exactly/exa

Length of output: 1103


🏁 Script executed:

#!/bin/bash
# Check if alchemyQueue.test.ts actually imports the redis mock
echo "=== Full alchemyQueue.test.ts import section ==="
head -50 server/test/queues/alchemyQueue.test.ts

echo ""
echo "=== Check if there's a pattern of importing redis mock in other tests ==="
grep -l "redis" server/test/**/*.test.ts 2>/dev/null

echo ""
echo "=== Check what happens when alchemyQueue is imported ==="
cat -n server/queues/alchemyQueue.ts | sed -n '1,75p'

echo ""
echo "=== Verify if DISABLE_WORKERS is set in vitest.config ==="
grep "DISABLE_WORKERS" server/vitest.config.mts || echo "DISABLE_WORKERS NOT found in vitest config"

Repository: exactly/exa

Length of output: 5147


🏁 Script executed:

#!/bin/bash
# Check how other queue tests handle this
echo "=== Check if there are other queue tests ==="
find server/test/queues -name "*.test.ts" -type f

echo ""
echo "=== Check if other queue test files import redis mock ==="
find server/test -name "*.test.ts" -type f -exec grep -l "alchemyQueue\|Queue\|Worker" {} \; 2>/dev/null | head -5

echo ""
echo "=== Check how block.test.ts (which uses redis) handles this ==="
head -20 server/test/hooks/block.test.ts 2>/dev/null

Repository: exactly/exa

Length of output: 738


🏁 Script executed:

#!/bin/bash
# Check what REDIS_URL is set to in vitest config for tests
echo "=== REDIS_URL value in vitest config ==="
grep -A 1 -B 1 "REDIS_URL" server/vitest.config.mts

echo ""
echo "=== Check if the alchemyQueue.test.ts file is actually testing processor or queue ==="
grep -n "processor\|alchemyQueue\|alchemyWorker" server/test/queues/alchemyQueue.test.ts

echo ""
echo "=== Check what the test is actually testing ==="
cat -n server/test/queues/alchemyQueue.test.ts | sed -n '34,100p'

Repository: exactly/exa

Length of output: 2952


Import the Redis mock to prevent connection attempts during test module initialization.

The test file imports from alchemyQueue.ts which instantiates a Redis connection at module load (line 23) without guarding it with DISABLE_WORKERS. While the Worker is only created if DISABLE_WORKERS is not set, the Redis connection itself happens unconditionally. The vitest.config.mts does not set DISABLE_WORKERS and does not provide a real Redis URL. Add import "../mocks/redis"; at the top of this test file, following the pattern used in other test files like server/test/hooks/block.test.ts, to mock Redis with ioredis-mock.

🤖 Prompt for AI Agents
In `@server/test/queues/alchemyQueue.test.ts` around lines 1 - 7, Add the Redis
mock import at the top of the test module to prevent real Redis connection
during module initialization: insert an import statement for the test Redis mock
(e.g., import "../mocks/redis";) as the very first import in
alchemyQueue.test.ts so it runs before importing the module that instantiates
Redis (the module that exports processor and AlchemyJob/AlchemyJobData from
../../queues/alchemyQueue), ensuring ioredis-mock is used during tests.

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.

3 participants