question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

count with rpc does not work as expected

See original GitHub issue

Bug report

Describe the bug

In the documentation, the following example does not work because it sets the params object instead.

const { data, error, count } = await postgrest
  .rpc('hello_world', { count: 'exact' })
}

A workaround is to provide undefined as the second argument to rpc, for example: .rpc('hello_world', undefined, { count: 'exact' }). I’m not sure if this is the intended behavior though so I filed as a bug report instead of docs improvement.

To Reproduce

You can add the following tests to /test/basic.ts. The 1st case fails and the 2nd one passes.

test("stored procedure with count but no params (1): 'exact'", async () => {
  const res = await postgrest.rpc('void_func', { count: 'exact' })
  expect(res.count).toBe(1)
})

test("stored procedure with count but no params (2): 'exact'", async () => {
  const res = await postgrest.rpc('void_func', undefined, { count: 'exact' })
  expect(res.count).toBe(1)
})

Expected behavior

According to the documentation, using rpc('hello_world', { count: 'exact' }) should return an object with count in it. I’m not sure what the optimal solution to this problem would be since both the params and { count: '...' } are optional.

System information

  • OS: macOS
  • Version of supabase-js: 1.21.0
  • Version of Node.js: v16.4.2

Additional context

A related problem is: in supabase/supabase.js, when using const supabase = createClient(), the { count: 'exact' } never works because it is never passed to postgrest-js.

I think I should file this issue in supabase/supabase.js instead.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
soedirgocommented, Aug 23, 2021

@PatoDeVille can you file a new issue in the supabase/postgrest-js repo about this? Would be helpful if you can provide the function definition as well.

1reaction
kiwicopplecommented, Aug 18, 2021

@soedirgo - I’ve add the fix to the docs, will let you approve/merge 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using RabbitMQ RPC doesn't fail when there is no consumer ...
I'm using the method rabbitTemplate.convertSendAndReceive from Spring RabbitMQ. This works as expected if the B is running. My code is very ...
Read more >
Photon Pun RPC not working as expected - Unity Forum
Hi, I am creating a multiplayer game with 3 people in the room. They all spawn in fine and I can cache each...
Read more >
How to configure RPC to use certain ports and how to help ...
First, the RPC dynamic port range should be restricted to a smaller, more manageable port range that is easier to block by using...
Read more >
Troubleshoot Dataflow errors - Google Cloud
If you run into problems with your Dataflow pipeline or job, this page lists error messages that you might see and provides suggestions...
Read more >
RabbitMQ tutorial - Remote procedure call (RPC)
It's due to a possibility of a race condition on the server side. Although unlikely, it is possible that the RPC server will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found