Skip to content

Fix/rpc no params react native#2017

Closed
dev-hari-prasad wants to merge 246 commits into
supabase:masterfrom
dev-hari-prasad:fix/rpc-no-params-react-native
Closed

Fix/rpc no params react native#2017
dev-hari-prasad wants to merge 246 commits into
supabase:masterfrom
dev-hari-prasad:fix/rpc-no-params-react-native

Conversation

@dev-hari-prasad

Copy link
Copy Markdown

🔍 Description

This PR improves request handling in the PostgREST client to make it more compatible with custom fetch implementations and fixes Husky hooks to avoid reliance on globally installed binaries.

What changed?

PostgREST client improvements

  • Updated PostgrestBuilder.ts to serialize request headers as a plain object instead of a Headers instance. This avoids compatibility issues with non-standard or custom fetch implementations.
  • Ensured that non-GET/HEAD requests without a body send an empty JSON object ({}) instead of undefined. This fixes edge cases like RPC calls without parameters.
  • Added tests in headers_serialization.test.ts to verify:
    • Headers are passed as plain objects.
    • RPC calls without parameters send {} as the request body.

Husky hook updates

  • Updated .husky/commit-msg and .husky/pre-push to use local binaries (./node_modules/.bin/...) instead of npx.
  • This removes dependency on global installs and reduces environment-related failures.

Why was this change needed?

  • Some environments (notably React Native and custom fetch setups) do not fully support the Headers API, causing requests to fail unexpectedly.
  • PostgREST expects a request body for certain operations (like RPC), and sending no body at all can lead to errors.
  • Using npx inside Husky hooks can break in CI or restricted environments where global binaries are unavailable.

Closes #1562 (if applicable)

📸 Screenshots / Examples

N/A – changes are covered by tests.

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality
  • I have updated documentation (not required for this change)

This PR fixes #1562

…ON body

Refactors PostgrestBuilder to serialize headers as a plain object instead of a Headers instance,
ensuring compatibility with environments expecting plain objects.

Also ensures that requests without a body send an empty JSON object for non-GET/HEAD methods.

Adds tests to verify header serialization and correct body handling.
@dev-hari-prasad dev-hari-prasad requested review from a team as code owners January 12, 2026 18:24
@dev-hari-prasad

Copy link
Copy Markdown
Author

@mandarini @avallete Pls check

edgurgel and others added 22 commits January 20, 2026 12:30
Co-authored-by: supabase-releaser[bot] <supabase-releaser[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
…2041)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…ime detection (supabase#2046)

Co-authored-by: Guilherme Souza <guilherme@supabase.io>
Co-authored-by: supabase-releaser[bot] <supabase-releaser[bot]@users.noreply.github.com>
mandarini and others added 16 commits May 21, 2026 14:53
Co-authored-by: supabase-releaser[bot] <supabase-releaser[bot]@users.noreply.github.com>
…across 1 directory (supabase#2401)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…minor-and-patch group (supabase#2403)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…sful responses (supabase#2398)

Co-authored-by: youcefzemmar <dzbuildoff@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dev-hari-prasad

Copy link
Copy Markdown
Author

Hey @mandarini, so sorry this almost slipped my mind, I was on a break. I'll look into this immediately now that I'm free and do the needful.

…ON body

Refactors PostgrestBuilder to serialize headers as a plain object instead of a Headers instance,
ensuring compatibility with environments expecting plain objects.

Also ensures that requests without a body send an empty JSON object for non-GET/HEAD methods.

Adds tests to verify header serialization and correct body handling.
@dev-hari-prasad dev-hari-prasad requested review from a team as code owners May 31, 2026 07:58
@dev-hari-prasad

Copy link
Copy Markdown
Author

Changes are made. Husky is cleaned, and I have rebased the branch with master. Let me know if any action is needed from my end.

CC: @mandarini

@pkg-pr-new

pkg-pr-new Bot commented Jun 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2017

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2017

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2017

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2017

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2017

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2017

commit: b8c500d

@mandarini

Copy link
Copy Markdown
Contributor

Hi @dev-hari-prasad ! Thank you for this contribution. The PR as it is, it's unmergeable, something went wrong during your rebase. In any case, I am putting in a new PR to fix the issue you were trying to solve. I will mention you in the PR description. Thank you for this PR, it highlighted a bug that needed to be addressed. Looking forward to your next contribution!

@mandarini mandarini closed this Jun 1, 2026
@dev-hari-prasad

Copy link
Copy Markdown
Author

Thanks! Totally works. Tag me in the new PR if my inputs are required.

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.

supabase-js rpc() fails with PGRST202 for parameter-less functions in React Native