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 fix] TypeError: Cannot destructure property 'resourceArn' of 'connection' as it is undefined. #3680

Closed
wants to merge 2 commits into from

Conversation

larryonward
Copy link

@larryonward larryonward commented Dec 4, 2024

Discussed here:
#3224
kudos to @NikolaRusakov for gist

I think what we see here is that drizzle-kit imports the CommonJS version of a package (@aws-sdk/client-rds-data) and driver imports ESM version of same package, and somehow it confuses instanceof

I was not able to replicate this use-case in vitest but I can provide debug screenshot
image
image

@larryonward
Copy link
Author

larryonward commented Dec 15, 2024

I'm not sure this is the best solution.
Alternatively (and might be safer) is to fix it in drizzle-kit package.
Something that works for me:

  1. In the drizzle config instead of
const client = new RDSDataClient({
  region: 'us-east-1',
});

export const db = drizzle(client, {
  database,
  secretArn,
  resourceArn,
});

initialize drizzle with

export const db = drizzle({
  connection: {
    database,
    secretArn,
    resourceArn,
  },

Now for drizzle-kit we want instead of

const db = drizzle(rdsClient, config);

To pass connection config and let the driver to create rdsClient instead of having it passed from cli

const db = drizzle({connection: config});

the patch command that fixes drizzle studio:
On mac

sed -i '' 's/drizzle(rdsClient, config)/drizzle({connection: config})/g' node_modules/drizzle-kit/bin.cjs

Ubuntu (e.g. for GH Actions):

sed -i 's/drizzle(rdsClient, config)/drizzle({connection: config})/g' node_modules/drizzle-kit/bin.cjs

@shixzie
Copy link

shixzie commented Feb 3, 2025

is this ready?

@bohdan-basov
Copy link

Hey guys 👋 Any updates on this?

@Idicious
Copy link

Idicious commented Feb 6, 2025

Any update on this issue?

@larryonward
Copy link
Author

closing in favor of #4114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants