Repository navigation
fix: emit Postgres column meta from result.fields (#11) - #12
Conversation
node-postgres 8.x never emits a Query `fields` event; column names live on result.fields during row/end. Emit NDJSON meta from those so hosts get non-empty columns for rowful and zero-row SELECTs. MySQL still uses the mysql2 fields event. Co-authored-by: zhangjing <zhangjing798@qq.com>
ChuTingzj
left a comment
There was a problem hiding this comment.
Verdict
Fixes #11 correctly. Root cause (listening for non-existent pg 8.x fields event) is real; result.fields on row/end + single meta is the right fix. Regression tests force the no-fields Query shape. Dockerfile includes the new module. No must-fix in code.
Follow-up (ops, not this PR)
GHCR digest / DEFAULT_SANDBOX_IMAGE / npm 0.1.4 still required after merge — consumers on the current digest keep empty Postgres columns until then.
Do not merge from this bot.
| if (settled) { | ||
| return; | ||
| } | ||
| emitMeta(result?.fields); |
There was a problem hiding this comment.
Fix matches #11. pg 8.x Query does not emit fields; reading result.fields on row/end with metaSent once is the right shape. Zero-row + legacy fields covered. MySQL left on fields event — good.
Order is correct for the host consumer: meta is written before the first row event.
| RUN npm install --omit=dev && npm cache clean --force | ||
|
|
||
| COPY execute.js stream-limit.js session-setup.js secrets.js events.js ./ | ||
| COPY execute.js stream-limit.js session-setup.js secrets.js events.js pg-query-stream.js ./ |
There was a problem hiding this comment.
Required for the fix to ship in GHCR — without this COPY the container would still run the old inlined path (or fail to resolve ./pg-query-stream.js). Good that it is in the same PR.
Reminder (not a code block): after merge, Publish runner → new digest → bump DEFAULT_SANDBOX_IMAGE + npm 0.1.4. Old digest stays broken for Postgres columns until then.
Regression stacked on the #12 runner fix: pg 8.x Result.fields must become NDJSON meta columns even when Query never emits a fields event. Co-authored-by: zhangjing <zhangjing798@qq.com>
Pin DEFAULT_SANDBOX_IMAGE to the GHCR digest from Publish runner after #12 (Postgres meta columns). Bump npm package to 0.1.4. Co-authored-by: Cursor Agent <cursoragent@cursor.com>


Fixes #11 — #11
Summary
Successful Postgres
executeSqlreturned rows with emptycolumns, so hosts that zipcolumns[i]ontovalues[i]produced{}objects.The mistake
The runner listened for a
fieldsevent onpg.Query. node-postgres 8.x never emitsfields. Field metadata is onresult.fieldswhenrow/endfire.Stdout was:
with no
{"type":"meta","columns":[...]}. HostconsumeNdjsonResulttherefore gotcolumns: [].MySQL is unchanged: mysql2 still emits
fields, andstreamMysqlstill uses that event.The fix
sandbox/pg-query-stream.jsemitsmetafromresult.fieldson the firstrowand/orend(at most once). Zero-row queries that still have a schema get columns onend. Afieldslistener remains as a no-op fallback for emitters that do fire it.Tests
Regression coverage uses a mock Query that never emits
fieldsand only providesresult.fields:metathen rows thenendmetathenendrow+endboth carry fields → a singlemetafieldsevent still works without duplicatingmetaexecute.jsstill listens forfieldsRunner image / npm
publish-runner.ymlpublishes on push tomain(sandbox/**) orworkflow_dispatch. This environment cannot dispatch that workflow (GitHub App 403: Resource not accessible by integration), and this PR is not merged, so GHCR:v1is not rebuilt from these commits yet.DEFAULT_SANDBOX_IMAGEstill pins the current digest until the Publish runner image job summary is available after merge (or a manualworkflow_dispatchof this branch).publish-npm.ymlflow — same two-step as ci: publish sandbox runner image to GHCR #2 → feat: pin DEFAULT_SANDBOX_IMAGE to published GHCR digest #3.Test plan
pnpm typecheck/pnpm test/pnpm buildlocally (58 tests, 0 failures)testjob green on this PRworkflow_dispatchof this branch): copy the new digest from the Publish runner image job summary intoDEFAULT_SANDBOX_IMAGE+ READMEpackage.jsonto 0.1.4 and tagv0.1.4when ready to publish npm