Skip to content

replicateSupabase push handler generates excessively long URLs by adding all document fields to WHERE clause #7986

@Zoltan3057

Description

@Zoltan3057

Description

When using replicateSupabase to synchronize documents with large text/JSON fields (like HTML content or rich text JSON), the push handler fails with 400 Bad Request errors. The issue occurs because the addDocEqualityToQuery function adds all document fields as equality conditions in the PATCH request URL, causing URL length limits to be exceeded.

Environment

RxDB: 17.0.0-beta.10
Plugin: rxdb/plugins/replication-supabase
Supabase: @supabase/supabase-js latest
Platform: Browser (Chrome/Firefox)

Steps to Reproduce

Create a Supabase table with text/JSON fields that can contain large content (e.g., HTML, rich text)
Set up RxDB collection with matching schema
Configure replicateSupabase with both pull and push enabled
Update a document that has large content fields
Observe the PATCH request in network tab - all fields are included as query params
Replication fails with 400 Bad Request when URL exceeds server limits

Root Cause Analysis

The issue is in addDocEqualityToQuery function (packages/replication-supabase/src/supabase-replication.ts). This function is called during the push handler for updates and adds every field from the assumedMasterState document as a WHERE condition to the PATCH request.


// Simplified view of what happens
let query = supabase
    .from('table_name')
    .update(updateData);
// This adds ALL fields from assumedMasterState as query parameters
query = addDocEqualityToQuery(assumedMasterState, query);


Expected Behavior

The push handler should generate PATCH requests that:
Use the request body for data, not URL query parameters
Only include necessary fields in WHERE clause for optimistic concurrency (primary key + modified timestamp)
Respect URL length limits (typically 2048-8192 characters)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions