feat: add Postgres-backed DPU job queue#444
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughImplements a PostgreSQL-backed DPU job queue (schema, operations, tests), adds DPU auth validation, three POST API routes (claim, ack, fail), routes publishMessage to the DB transport when configured, and updates setup UI/Docker instructions to default to self-hosting. ChangesDPU Job Queue Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review this PR again. |
|
✅ Action performedFull review finished. |
|
|
||
| const HostingSelector: React.FC<HostingSelectorProps> = ({ selectedHosting, setSelectedHosting }) => { | ||
| const hostingOptions = [ | ||
| { value: 'cloud', label: 'Vibinex Cloud' }, |
There was a problem hiding this comment.
I feel that you should only leave this commented out, and not totally remove this option. Unless you don't intend to bring it back again.
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/setup/DockerInstructions.tsx`:
- Line 21: Update the Docker instructions to use the supported transport value
by replacing the DPU_QUEUE_TRANSPORT environment value from "http" to
"postgres"; this aligns with the runtime switch in utils/pubsub/pubsubClient.ts
which only recognizes 'postgres' (otherwise it falls back to Pub/Sub) so update
the DPU_QUEUE_TRANSPORT entry in DockerInstructions.tsx to "postgres".
In `@utils/db/dpuJobs.ts`:
- Around line 6-16: The DpuJob interface declares id as string but claimDpuJobs
currently returns raw DB rows (numeric BIGSERIAL ids); fix claimDpuJobs by
mapping result.rows to a proper DpuJob shape and convert row.id to string (e.g.,
id: String(row.id)) before returning, mirroring the conversion used in
enqueueDpuJob; ensure the mapping uses the same field names (installation_id,
msg_type, payload, status, attempts, locked_until, created_at, updated_at) so
consumers always receive ids as strings.
- Around line 40-47: The schemaReady promise set in ensureDpuJobsTable can
remain rejected after conn.query(DPU_JOBS_SCHEMA_SQL) fails, causing all future
calls to await the same rejected promise; modify ensureDpuJobsTable so that when
creating schemaReady it attaches rejection handling that clears schemaReady (set
back to null) on error before re-throwing the error (e.g., use
conn.query(...).then(() => undefined).catch(err => { schemaReady = null; throw
err; })), referencing schemaReady, ensureDpuJobsTable, conn.query, and
DPU_JOBS_SCHEMA_SQL in your change.
In `@utils/dpuAuth.ts`:
- Around line 14-16: The current token check in utils/dpuAuth.ts uses direct
string comparison (providedToken !== configuredToken) which is vulnerable to
timing attacks; replace it with a constant-time comparison using Node's
crypto.timingSafeEqual by converting both tokens to Buffers, first verify both
are defined and have the same byte length (otherwise treat as non-match), and
then call crypto.timingSafeEqual to decide to send res.status(401).json({ error:
'Unauthorized' }) and return false (ensure the same error path is used for
length mismatch and failed comparison); update the logic around
providedToken/configuredToken in the authentication function to follow this safe
comparison flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 31c05d22-0eba-4b7d-9a2e-c395476d78a0
📒 Files selected for processing (11)
components/setup/DockerInstructions.tsxcomponents/setup/HostingSelector.tsxpages/api/dpu/jobs/ack.tspages/api/dpu/jobs/claim.tspages/api/dpu/jobs/fail.tspages/docs/setup/hosting.tsxpages/docs/setup/providerAppInstall.tsxutils/db/__tests__/dpuJobs.test.tsutils/db/dpuJobs.tsutils/dpuAuth.tsutils/pubsub/pubsubClient.ts
💤 Files with no reviewable changes (1)
- components/setup/HostingSelector.tsx
- HostingSelector: comment out cloud option instead of deleting (per Avikalp) - DockerInstructions: fix DPU_QUEUE_TRANSPORT from 'http' to 'postgres' (pubsubClient only matches 'postgres') - dpuJobs: reset schemaReady to null on rejection so it can recover after transient DB errors - dpuJobs: map claimDpuJobs rows to convert BIGSERIAL id to string, matching DpuJob interface - dpuAuth: use crypto.timingSafeEqual instead of !== for timing-safe token comparison
|
All review comments addressed in the latest commit ( Avikalp's comment — HostingSelector.tsx:
CodeRabbit — 4 issues:
|
Summary
Paired PRs
Verification
Notes
Summary by CodeRabbit
New Features
Changes
Documentation
Tests