denodrivers / postgres

PostgreSQL driver for Deno

Home Page:https://denodrivers.github.io/postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read properties of undefined (reading 'push')

ChristianSiegert opened this issue · comments

I have received the following error many times now (but cannot reproduce it reliably):

error: (in promise) TypeError: Cannot read properties of undefined (reading 'push')
          () => this.#available_connections!.push(client),
                                             ^
    at PoolClient.<anonymous> ([redacted]/vendor/deno.land/x/postgres@v0.16.1/pool.ts:191:46)
    at PoolClient.release ([redacted]/vendor/deno.land/x/postgres@v0.16.1/client.ts:499:18)

pool.ts line 191 reads:

() => this.#available_connections!.push(client),

The exclamation mark is code smell because it suppresses a compiler warning. Without it, deno complains this.#available_connections is possibly 'undefined'. I think this case should be handled properly.