Skip to content

refactor: remove server mode, router mode is now the only runtime path#644

Merged
zbigniewsobiecki merged 2 commits intodevfrom
feature/remove-server-mode-router-mode
Mar 7, 2026
Merged

refactor: remove server mode, router mode is now the only runtime path#644
zbigniewsobiecki merged 2 commits intodevfrom
feature/remove-server-mode-router-mode

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 7, 2026

Summary

Removes the server (single-process/fire-and-forget) execution mode, leaving only router mode as the sole runtime path. This eliminates ~400 lines of dead code and in-process queuing logic that was superseded by the BullMQ worker architecture.

Card: https://trello.com/c/69abfd306dcb3c2a6207feb8

What was changed

  • Deleted src/index.ts + src/server.ts (monolithic entry point, replaced by src/router/index.ts)
  • Deleted src/server/webhookReactionSender.ts (server-mode-only reaction sender)
  • Deleted src/utils/webhookQueue.ts (in-process webhook queue, replaced by BullMQ/Redis)
  • Deleted src/utils/activeCards.ts (in-process active card tracking, no longer needed)
  • Deleted src/triggers/shared/webhook-queue.ts (in-process queue processor)
  • Created src/webhook/ module with relocated webhook handler factory, parsers, logging helpers, and types from src/server/
  • Simplified src/webhook/webhookHandlers.ts — router-only factory: always awaits processWebhook, errors propagate to Hono's error handler
  • Simplified src/pm/webhook-handler.ts — removed isCurrentlyProcessing, enqueueWebhook, setCardActive/clearCardActive, processNextQueued and setProcessing calls
  • Simplified src/triggers/github/webhook-handler.ts — same simplifications for GitHub webhook handler
  • Simplified src/utils/lifecycle.ts — removed setProcessing/isCurrentlyProcessing exports
  • Simplified src/utils/index.ts — removed re-exports for deleted utils
  • Updated package.jsonmain, dev, start scripts now point to src/router/index.ts
  • Updated .cascade/setup.sh, .cascade/ensure-services.sh, .cascade/env — added Redis setup and health check (required for router mode / BullMQ)
  • Updated .env.example — added REDIS_URL documentation
  • Updated CLAUDE.md, README.md — new three-service architecture, Redis prerequisite, updated directory structure

Test changes

  • Deleted tests/unit/server.test.ts (server mode integration tests)
  • Deleted tests/unit/utils/webhookQueue.test.ts (in-process queue tests)
  • Deleted tests/unit/utils/activeCards.test.ts (active cards tests)
  • Deleted tests/unit/triggers/webhook-queue.test.ts (webhook-queue processor tests)
  • Deleted tests/unit/server/ (server-mode unit tests)
  • Created tests/unit/webhook/webhookHandlers.test.ts — updated for router-only behavior
  • Created tests/unit/webhook/webhookParsers.test.ts — relocated from tests/unit/server/
  • Updated tests/unit/pm/webhook-handler.test.ts — removed server-mode tests
  • Updated tests/unit/triggers/github-webhook-handler.test.ts — removed server-mode tests
  • Updated tests/unit/utils/lifecycle.test.ts — removed setProcessing/isCurrentlyProcessing tests

Test plan

  • All 3921 unit tests pass
  • TypeScript type checking passes (zero errors)
  • Lint passes (zero errors/warnings)
  • src/router/index.ts is the sole entry point for the application

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

Summary

Clean, well-organized removal of ~400 lines of dead server-mode code. One file was missed in the cleanup: src/webhook/webhookTypes.ts still contains the now-unused checkCapacity and fireAndForget properties and their JSDoc references. Everything else looks good — no dangling imports, CI passes, tests properly updated.

Code Issues

Should Fix

  • src/webhook/webhookTypes.ts:64-82 — The WebhookHandlerConfig interface still declares checkCapacity?: boolean and fireAndForget?: boolean with their associated JSDoc, even though webhookHandlers.ts no longer destructures or uses these properties. The processWebhook JSDoc (lines 44-56) also still describes fireAndForget branching logic that was removed in this PR.

    Fix: Delete lines 64-82 (the two stale optional properties and their JSDoc) and simplify the processWebhook JSDoc to reflect router-only (always-await) semantics. Something like:

    /**
     * Processing callback. The handler awaits this callback before responding,
     * so 200 means "job queued." Errors propagate to Hono's error handler (500).
     *
     * May optionally return `WebhookLogOverrides` to enrich the webhook log entry.
     */

Removes the unused `fireAndForget` and `checkCapacity` properties from
`WebhookHandlerConfig` interface along with their associated JSDoc.
Also simplifies the `processWebhook` JSDoc to reflect router-only
(always-await) semantics.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

LGTM — Clean removal of the server (single-process) execution mode. The refactoring is thorough and consistent:

  • All in-process queuing logic (webhookQueue, activeCards, isCurrentlyProcessing/setProcessing) is fully removed from source, tests, and barrel exports — no stale references remain.
  • The WebhookHandlerConfig interface is properly simplified: fireAndForget and checkCapacity options removed, leaving only the router-mode await path.
  • Error handling in createWebhookHandler correctly logs to Sentry via handleProcessingError then re-throws to Hono's error handler — preserving the existing router behavior.
  • The src/server/src/webhook/ rename cleanly separates shared webhook parsing/logging from the old monolithic server module.
  • All 3921 unit tests pass, TypeScript compiles with zero errors, and CI is green.
  • Documentation (CLAUDE.md, README.md, .env.example) and infrastructure scripts (.cascade/setup.sh, ensure-services.sh) are updated for the Redis/BullMQ dependency.

@zbigniewsobiecki zbigniewsobiecki merged commit d20cf88 into dev Mar 7, 2026
6 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the feature/remove-server-mode-router-mode branch March 16, 2026 16:43
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