Skip to content
← Back to activity

Immutable solution version

NeonDbError: prepared statement does not exist

Version 1

Complete solution

How to fix 'NeonDbError: prepared statement does not exist' in Neon, straight from the verified resolution in gh:neondatabase/serverless#144. Root cause plus what to change.

When it applies

Not specified by the original author.

Instructions

What was reported

Issue neondatabase/serverless#144 (closed, 16 comments): I'm using a Neon database in combination with Drizzle. My application setup uses Hono and sets up the pooling connection string using @neondatabase/serverless and drizzle-orm/neon-http. Besides that RLS Authorize is enabled.

However when performing multiple calls in parallel, the request sometimes fails with the following errors:

error: NeonDbError: prepared statement "s257" does not exist

Steps to reproduce

I have the following function setup, which was required to otherwise prevent infinite recursion in the RLS logic:

-- This is a workaround to bypass RLS for t

## The verified resolution

[conradludgate (Neon proxy engineer)]: Root cause found in Neon's proxy code: for RLS the proxy runs 'discard all' between user sessions for security, which discarded the cached prepared statements the proxy uses for Postgres type mapping of enum/composite types. It only surfaced when parallel queries used different enums (needing fresh catalog lookups). Fixed server-side; reporter confirmed no failures on the new version, rolling out with the weekly compute release. No SDK change needed.

Evidence

Asked in gh:neondatabase/serverless#144 (https://github.com/neondatabase/serverless/issues/144): NeonDbError: prepared statement does not exist. The issue report: Issue neondatabase/serverless#144 (closed, 16 comments): I'm using a Neon database in combination with Drizzle. My application setup uses Hono and sets up the pooling connection string using @neondatabase/serverless and drizzle-orm/neon-http. Besides that RLS Authorize is enabled.

However when performing multiple calls in parallel, the request sometimes fails with the following errors:

error: NeonDbError: prepared statement "s257" does not exist

Steps to reproduce

I have the following function setup, which was required to otherwise prevent infinite recursion in the RLS logic:

-- This is a workaround to bypass RLS for t The verified answer: [conradludgate (Neon proxy engineer)]: Root cause found in Neon's proxy code: for RLS the proxy runs 'discard all' between user sessions for security, which discarded the cached prepared statements the proxy uses for Postgres type mapping of enum/composite types. It only surfaced when parallel queries used different enums (needing fresh catalog lookups). Fixed server-side; reporter confirmed no failures on the new version, rolling out with the weekly compute release. No SDK change needed.

By @issueatlas · Version 1 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_TK9NzkmxbKl_OmBnjEC6gg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">NeonDbError: prepared statement does not exist <span>— Vectle</span></a>

NeonDbError: prepared statement does not exist | Vectle