Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: TypeError: The ResolveMessage.message getter can only be used on instances of ResolveMessage #1370

Closed
milan-codes opened this issue Oct 14, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@milan-codes
Copy link

What version of drizzle-orm are you using?

0.28.6

What version of drizzle-kit are you using?

0.19.13

Describe the Bug

I've initialized a new bun project with bun init, installed Drizzle, and tried connecting to a local database, with the following code:

import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { user } from './schema/user';

const client = postgres(process.env.DATABASE_URL!);
const db = drizzle(client, { schema: { user } });

await db.select().from(user);

In my user schema I have:

import { serial, varchar, boolean, timestamp, pgTable } from 'drizzle-orm/pg-core';

export const user = pgTable('users', {
  id: serial('id').primaryKey(),
  email: varchar('email', { length: 254 }).unique(),
  emailVerified: boolean('email_verified').default(false),
  password: varchar('password', { length: 64 }).notNull(),
  createdAt: timestamp('created_at').notNull().defaultNow(),
});

Finally, this is my drizzle.config.ts:

import type { Config } from 'drizzle-kit';

export default {
  schema: './schema',
  out: './drizzle',
  driver: 'pg',
  dbCredentials: {
    connectionString: process.env.DATABASE_URL!,
  },
} satisfies Config;

Running await db.select().from(user), or any other query, throws the following error:

TypeError: The ResolveMessage.message getter can only be used on instances of ResolveMessage

I have made a repository where you can reproduce this issue.

Expected behavior

Running await db.select().from(user) should return with the users from the database.

Environment & setup

I've encountered this issue on:

  • macOS Sonoma 14.0
  • Linux 6.1.57-1-lts (Arch)

Both systems use bun 1.0.6

@milan-codes milan-codes added the bug Something isn't working label Oct 14, 2023
@trylovetom
Copy link

same here, I get the message below

$ bun src/scripts/migrate.ts
[migrate.ts]: migration started at 2023-10-14T15:57:57.639Z.
Query: CREATE SCHEMA IF NOT EXISTS "drizzle"
ResolveMessage {
  stack: "undefined",
  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]
}

@trylovetom
Copy link

I thing this problem come from postgres.js, relate to porsager/postgres#692

@trylovetom
Copy link

the workaround is downgrade the postgres.js to v3.3.5, such as

"dependencies": {
    "drizzle-orm": "^0.28.6",
+    "postgres": "3.3.5",
-    "postgres": "^3.3.5",
 }

@milan-codes
Copy link
Author

Can confirm @trylovetom, this seems like an issue with postgres.js, downgrading solved the problem for me as well.

yamcodes added a commit to agnyz/the-bed-stack that referenced this issue Oct 16, 2023
@trylovetom
Copy link

@milan-codes Now you can update postgres.js to v3.4.1. It's fixed

@milan-codes
Copy link
Author

Fixed by upgrading postgres.js to 3.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants