functions-js
functions-js copied to clipboard
Fixed leaking resources when a fetch response body is not consumed
What kind of change does this PR introduce?
Bug fix (fixes https://github.com/supabase/functions-js/issues/65)
What is the current behavior?
I am trying to write some negative tests for my edge functions, for example:
const testSomeFunction = async () => {
const { data, error } = await supabaseUser.functions.invoke('some-function', {
body: {
userId: 'invalid-id'
}
})
assertEquals(error.message, 'Edge Function returned a non-2xx status code')
assertEquals(data, null)
}
But when running deno test, the test fails with:
error: Leaking resources:
- A fetch response body (rid 18) was created during the test, but not consumed during the test. Consume or close the response body `ReadableStream`, e.g `await resp.text()` or `await resp.body.cancel()`.
But I cannot access the response to consume/close/cancel/... it.
What is the new behavior?
The response body is cancelled if necessary.