fix(plugin): read channel self get from replica#2266
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR modifies PostgreSQL client initialization in the channel self PUT endpoint by adding a ChangesChannel Self PG Client Configuration
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 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 unit tests (beta)
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/files-app-read-guard.unit.test.ts (1)
37-37: ⚡ Quick winUse
it.concurrent()for the updated test cases.Both changed tests should use
it.concurrent()to match the suite’s parallel-execution requirement.♻️ Suggested change
- it('serves cached app-scoped files without app lookup', async () => { + it.concurrent('serves cached app-scoped files without app lookup', async () => {- it('serves cached malformed app-scoped paths without app lookup', async () => { + it.concurrent('serves cached malformed app-scoped paths without app lookup', async () => {As per coding guidelines "
tests/**/*.test.ts: Design all tests for parallel execution across files; use it.concurrent() instead of it() to run tests in parallel within the same file for faster CI/CD".Also applies to: 75-75
🤖 Prompt for 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. In `@tests/files-app-read-guard.unit.test.ts` at line 37, Replace the two synchronous tests that use it(...) with parallel execution by changing them to it.concurrent(...); specifically update the test whose title is "serves cached app-scoped files without app lookup" and the other modified test at the second location (line referenced in comment) to call it.concurrent instead of it so they run in parallel with the suite's requirements.tests/files-security.test.ts (1)
220-220: ⚡ Quick winUse
it.concurrent()for this updated test case.Switch this updated test to
it.concurrent()to keep the file aligned with parallel-test policy.♻️ Suggested change
- it('continues serving uploaded attachments while the storage object still exists after the app is deleted', async () => { + it.concurrent('continues serving uploaded attachments while the storage object still exists after the app is deleted', async () => {As per coding guidelines "
tests/**/*.test.ts: Design all tests for parallel execution across files; use it.concurrent() instead of it() to run tests in parallel within the same file for faster CI/CD".🤖 Prompt for 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. In `@tests/files-security.test.ts` at line 220, The test case "continues serving uploaded attachments while the storage object still exists after the app is deleted" uses it(...) but should use it.concurrent(...) to enable parallel execution; update the test invocation in tests/files-security.test.ts by replacing the it(...) call wrapping that async test with it.concurrent(...), preserving the async function body and any timers/timeouts or shared fixtures so the test remains safe to run in parallel.
🤖 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.
Nitpick comments:
In `@tests/files-app-read-guard.unit.test.ts`:
- Line 37: Replace the two synchronous tests that use it(...) with parallel
execution by changing them to it.concurrent(...); specifically update the test
whose title is "serves cached app-scoped files without app lookup" and the other
modified test at the second location (line referenced in comment) to call
it.concurrent instead of it so they run in parallel with the suite's
requirements.
In `@tests/files-security.test.ts`:
- Line 220: The test case "continues serving uploaded attachments while the
storage object still exists after the app is deleted" uses it(...) but should
use it.concurrent(...) to enable parallel execution; update the test invocation
in tests/files-security.test.ts by replacing the it(...) call wrapping that
async test with it.concurrent(...), preserving the async function body and any
timers/timeouts or shared fixtures so the test remains safe to run in parallel.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 373c8c29-5a9f-4e79-a96e-1494eb65154a
📒 Files selected for processing (4)
supabase/functions/_backend/files/files.tstests/files-app-read-guard.unit.test.tstests/files-local-read-proxy.unit.test.tstests/files-security.test.ts
✅ Files skipped from review due to trivial changes (1)
- supabase/functions/_backend/files/files.ts
e1f6306 to
87f8c60
Compare
|
I think this should stay on the primary for the legacy override path, or split the handler so only the local-storage/new-plugin branch can use the replica.
That makes the immediate read-after-write path replica-lag dependent: a device can successfully self-assign to a channel, then its next A narrow fix would be to keep |
87f8c60 to
a6cb494
Compare
|



Summary (AI generated)
/channel_selfPUT read requests through the read-replica Postgres client.channel_devices.Motivation (AI generated)
Supabase reported plugin workers still opening direct primary Postgres sessions. The legacy
/channel_selfPUT handler is a read action, so it should use the existing read-replica path instead of the write/default connection.Business Impact (AI generated)
This reduces primary database connection pressure for old plugin channel reads without changing public API responses or legacy write behavior.
Test Plan (AI generated)
bun lint:backendbun typecheckbun run supabase:with-env -- bunx vitest run tests/channel_self.test.ts --fileParallelism=false --hookTimeout=60000Generated with AI
Summary by CodeRabbit