porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.42k stars 271 forks source link

error: ResolveMessage after upgrade to v 3.4.0 #692

Closed masfahru closed 12 months ago

masfahru commented 1 year ago

Runtime : bun 1.0.4+745b6b94ee56cad24d475799690cc9a89957d15b

Updating Postgres.js from 3.3.5 to 3.4.0, but then I got an error: ResolveMessage when executing a query.

ResolveMessage {
  stack: "undefined\n    at cachedError (/home/fahru/github-collections/postgres/node_modules/postgres/cf/src/query.js:171:27)\n    at new Query (/home/fahru/github-collections/postgres/node_modules/postgres/cf/src/query.js:35:47)\n    at sql (/home/fahru/github-collections/postgres/node_modules/postgres/cf/src/index.js:115:37)\n    at module code (/home/fahru/github-collections/postgres/index.ts:15:2)",
  query: undefined,
  parameters: undefined,
  args: [],
  types: null,
  code: undefined,
  importKind: undefined,
  level: undefined,
  message: undefined,
  position: undefined,
  referrer: undefined,
  specifier: undefined,
  toJSON: [Function: toJSON],
  toString: [Function: toString],
  name: "ResolveMessage",
  [Symbol(Symbol.toPrimitive)]: [Function: toPrimitive]
}

Code to reproduce

import postgres from 'postgres';

const sql = postgres({
  host: 'random-generated-host.ap-southeast-1.aws.neon.tech',
  port: 5432,
  username: 'user_name',
  password: 'strong_password',
  database: 'database_name',
  ssl: true,
  max: 1,
  transform: postgres.camel,
});

await sql`SELECT id, "name", batch, migration_time FROM knex_migrations`.then((res) => {
  console.info(res)
  return res
}).catch((error) => {
  console.error(error)
})

It works on v 3.3.5 image

codewith-luke commented 1 year ago

Can confirm, seeing the same behavior in Bun as well since the upgrade.

porsager commented 1 year ago

Why oh why is bun choosing the worker export (that is meant for CloudFlare)šŸ«£ I'll look a little closer.

Ychop commented 1 year ago

Same here with bun 1.0.6 for Postgres.js 3.3.5 and 3.4.0

lukeed commented 12 months ago

Bun checks for bun -> worker -> node -> require -> import -> default

https://bun.sh/docs/runtime/modules#importing-packages

porsager commented 12 months ago

Thanks a lot @lukeed - I'll add a specific pointer for bun so it doesn't grab the cloudflare one