macvim
macvim
DTDrizzle Team
Created by macvim on 5/3/2023 in #help
RangeError: Maximum call stack size exceeded - When I try to INSERT
Hi, I am getting RangeError: Maximum call stack size exceeded when I try to INSERT something in the DB, SELECT queries works with no issues. I am using "drizzle-orm": "^0.25.3" and "@remix-run/react": "^1.15.0". I have a page to add an organization with the following action:
export const action = async ({ request, context }: ActionArgs) => {
const db = getDbFromContext(context);
const { errors, data } = await getValidatedFormData<FormData>(
request,
resolver
);
if (errors) {
return json(errors);
}
const org = await putOrg(db, data);
return org;
};
export const action = async ({ request, context }: ActionArgs) => {
const db = getDbFromContext(context);
const { errors, data } = await getValidatedFormData<FormData>(
request,
resolver
);
if (errors) {
return json(errors);
}
const org = await putOrg(db, data);
return org;
};
putOrg functions in a server.ts file:
export async function putOrg(db: DrizzleD1Database, org: newOrg) {
const ts = new Date().getUTCSeconds();

const Org: NewOrgsModel = {
id: uuid(),
name: org.org,
description: org.description,
updatedAT: ts,
createdAT: ts,
};

try {
const insert = await db.insert(orgs).values(Org).returning().run();
return insert;
} catch (e) {
console.log("error catched: " + e);
}

}
export async function putOrg(db: DrizzleD1Database, org: newOrg) {
const ts = new Date().getUTCSeconds();

const Org: NewOrgsModel = {
id: uuid(),
name: org.org,
description: org.description,
updatedAT: ts,
createdAT: ts,
};

try {
const insert = await db.insert(orgs).values(Org).returning().run();
return insert;
} catch (e) {
console.log("error catched: " + e);
}

}
when this line get executed, I get the following error:
[wrangler] RangeError: Maximum call stack size exceeded
[wrangler] at deprecate (/private/Users/macvim/remix_project/functions/[[path]].js:45405:10)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:14)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] RangeError: Maximum call stack size exceeded
[wrangler] at deprecate (/private/Users/macvim/remix_project/functions/[[path]].js:45405:10)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:14)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
[wrangler] at warned (/private/Users/macvim/remix_project/functions/[[path]].js:45408:33)
org schema is defined here:
export const orgs = sqliteTable(
"orgs",
{
id: text("ID").notNull(),
name: text("Name").notNull(),
description: text("Description").notNull(),
updatedAT: integer("Updated_at").notNull(),
createdAT: integer("Created_at").notNull(),
},
(orgs) => ({
compositePk: primaryKey(orgs.id),
stripeCheckoutSessionIdIdx: index("orgsId").on(orgs.id),
})
);
export const orgs = sqliteTable(
"orgs",
{
id: text("ID").notNull(),
name: text("Name").notNull(),
description: text("Description").notNull(),
updatedAT: integer("Updated_at").notNull(),
createdAT: integer("Created_at").notNull(),
},
(orgs) => ({
compositePk: primaryKey(orgs.id),
stripeCheckoutSessionIdIdx: index("orgsId").on(orgs.id),
})
);
I think the issues I am having is similar to this: https://discord.com/channels/1043890932593987624/1092908217983578184 but I am not 100% sure. Any help is much appreciated. Thanks
6 replies