2 | import { isObject, isString } from './object-utils.js';
3 | export function extendStackTrace(err, stackError) {
4 | if (isStackHolder(err) && stackError.stack) {
5 | // Remove the first line that just says `Error`.
6 | const stackExtension = stackError.stack.split('\n').slice(1).join('\n');
7 | err.stack += `\n${stackExtension}`;
^
TypeError: Attempted to assign to readonly property.
at extendStackTrace (..../node_modules/kysely/dist/esm/util/stack-trace-utils.js:7:8)
at ..../node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:18
Which seems to be the Postgres library adding on extra information on the Error stack prop.
The following is the actual Postgres error which I got with Node 18
error: insert or update on table "users" violates foreign key constraint "users_workgroupId_fkey"
at <anonymous> (..../node_modules/.pnpm/pg@8.11.1/node_modules/pg/lib/client.js:526:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at PostgresConnection.executeQuery (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)
at <anonymous> (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28)
at DefaultConnectionProvider.provideConnection (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
at DefaultQueryExecutor.executeQuery (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:36:16)
at InsertQueryBuilder.execute (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-builder/insert-query-builder.js:534:24)
at InsertQueryBuilder.executeTakeFirst (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-builder/insert-query-builder.js:549:26)
at <anonymous> (..../src/routers/usersRouter.ts:104:17)
at <anonymous> (..../node_modules/.pnpm/hono@3.2.6/node_modules/hono/dist/cjs/middleware/cors/index.js:62:7)
at PostgresConnection.executeQuery (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at <anonymous> (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28)
at DefaultConnectionProvider.provideConnection (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
at DefaultQueryExecutor.executeQuery (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:36:16)
at InsertQueryBuilder.execute (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-builder/insert-query-builder.js:534:24)
at InsertQueryBuilder.executeTakeFirst (..../node_modules/.pnpm/kysely@0.25.0/node_modules/kysely/dist/cjs/query-builder/insert-query-builder.js:549:26)
at <anonymous> (..../src/routers/usersRouter.ts:104:17)
at <anonymous> (..../node_modules/.pnpm/hono@3.2.6/node_modules/hono/dist/cjs/middleware/cors/index.js:62:7)
at <anonymous> (..../node_modules/.pnpm/hono@3.2.6/node_modules/hono/dist/cjs/middleware/logger/index.js:63:5) {
length: 294,
severity: 'ERROR',
code: '23503',
detail: 'Key (workgroupId)=(983713cd-dad6-47ff-8eb8-3347f644782f) is not present in table "workgroups".',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'users',
column: undefined,
dataType: undefined,
constraint: 'users_workgroupId_fkey',
file: 'ri_triggers.c',
line: '2528',
routine: 'ri_ReportViolation'
}
Is this something that can be resolved with some method I have not thought about?
What version of Bun is running?
0.6.10
What platform is your computer?
Linux 6.2.6-76060206-generic x86_64 x86_64
What steps can reproduce the bug?
I'm running a Hono server with Kysely ORM with node-postgres driver.
I had a Foreign Key error with the following Kysely function:
With bun I get the following error:
Which seems to be the Postgres library adding on extra information on the Error stack prop.
The following is the actual Postgres error which I got with Node 18
Is this something that can be resolved with some method I have not thought about?
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response