Skip to content

Fix/rpc no params react native#2017

Open
dev-hari-prasad wants to merge 3 commits intosupabase:masterfrom
dev-hari-prasad:fix/rpc-no-params-react-native
Open

Fix/rpc no params react native#2017
dev-hari-prasad wants to merge 3 commits intosupabase: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

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale because it has not had activity for 90 days.
It will be closed in 14 days if no further activity occurs.

Please rebase and update if this is still needed.

@github-actions github-actions bot added the stale label Apr 19, 2026
Copy link
Copy Markdown
Contributor

@mandarini mandarini left a comment

Choose a reason for hiding this comment

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

@dev-hari-prasad can you please rebase and resolve conflicts, and remove changes to the .husky dir?

@dev-hari-prasad
Copy link
Copy Markdown
Author

@dev-hari-prasad can you please rebase and resolve conflicts, and remove changes to the .husky dir?

Sure, give me a day or two, I will do the required and rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants