-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Stack traces are awful #12044
Comments
Any help with modernizing our code-base will be appreciated :) |
Oh okay, yeah I'll start working on some of that stuff, glad the plan is to switch to async! |
FYI we should try using https://github.com/sgilroy/async-await-codemod before doing any of that work by hand |
It works on a lot of things 🎉 but not on the bluebird stuff. I'll look into writing a codemod to automatically convert bluebird things |
I'm having a hard time getting |
Can you show me the command you're running? Maybe it's in the script argument position instead of the node argument position |
We can close this now too right? |
Validation or client side errors have improved significantly ValidationError [SequelizeValidationError]: notNull Violation: User.name cannot be null
at InstanceValidator._validate (/var/projects/oss/sequelize/lib/instance-validator.js:78:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async InstanceValidator._validateAndRunHooks (/var/projects/oss/sequelize/lib/instance-validator.js:111:7)
at async InstanceValidator.validate (/var/projects/oss/sequelize/lib/instance-validator.js:93:12)
at async model.save (/var/projects/oss/sequelize/lib/model.js:3867:7)
at async Function.create (/var/projects/oss/sequelize/lib/model.js:2195:12)
at async /var/projects/oss/sequelize/sscce.js:27:3 {
name: 'SequelizeValidationError',
errors: [
ValidationErrorItem {
message: 'User.name cannot be null',
type: 'notNull Violation',
path: 'name',
value: null,
origin: 'CORE',
instance: [User],
validatorKey: 'is_null',
validatorName: null,
validatorArgs: []
}
]
} But we can still improve database errors. We can inject stack trace from original caller so it shows what method is failing, like UniqueConstraintError [SequelizeUniqueConstraintError]: Validation error
at Query.formatError (/var/projects/oss/sequelize/lib/dialects/postgres/query.js:338:18)
at Query.run (/var/projects/oss/sequelize/lib/dialects/postgres/query.js:87:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
name: 'SequelizeUniqueConstraintError',
errors: [
ValidationErrorItem {
message: 'id must be unique',
type: 'unique violation',
path: 'id',
value: '1',
origin: 'DB',
instance: [User],
validatorKey: 'not_unique',
validatorName: null,
validatorArgs: []
}
],
fields: { id: '1' },
parent: error: duplicate key value violates unique constraint "Users_pkey"
at Connection.parseE (/var/projects/oss/sequelize/node_modules/pg/lib/connection.js:614:13)
at Connection.parseMessage (/var/projects/oss/sequelize/node_modules/pg/lib/connection.js:413:19)
at Socket.<anonymous> (/var/projects/oss/sequelize/node_modules/pg/lib/connection.js:129:22)
at Socket.emit (events.js:311:20)
at addChunk (_stream_readable.js:294:12)
at readableAddChunk (_stream_readable.js:275:11)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
name: 'error',
length: 173,
severity: 'ERROR',
code: '23505',
detail: 'Key (id)=(1) already exists.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'Users',
column: undefined,
dataType: undefined,
constraint: 'Users_pkey',
file: 'nbtinsert.c',
line: '432',
routine: '_bt_check_unique',
sql: 'INSERT INTO "Users" ("id","name","createdAt","updatedAt") VALUES ($1,$2,$3,$4) RETURNING "id","name","createdAt","updatedAt";',
parameters: [
1,
'a',
'2020-05-23 05:53:06.183 +00:00',
'2020-05-23 05:53:06.183 +00:00'
]
},
original: error: duplicate key value violates unique constraint "Users_pkey"
at Connection.parseE (/var/projects/oss/sequelize/node_modules/pg/lib/connection.js:614:13)
at Connection.parseMessage (/var/projects/oss/sequelize/node_modules/pg/lib/connection.js:413:19)
at Socket.<anonymous> (/var/projects/oss/sequelize/node_modules/pg/lib/connection.js:129:22)
at Socket.emit (events.js:311:20)
at addChunk (_stream_readable.js:294:12)
at readableAddChunk (_stream_readable.js:275:11)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
name: 'error',
length: 173,
severity: 'ERROR',
code: '23505',
detail: 'Key (id)=(1) already exists.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'Users',
column: undefined,
dataType: undefined,
constraint: 'Users_pkey',
file: 'nbtinsert.c',
line: '432',
routine: '_bt_check_unique',
sql: 'INSERT INTO "Users" ("id","name","createdAt","updatedAt") VALUES ($1,$2,$3,$4) RETURNING "id","name","createdAt","updatedAt";',
parameters: [
1,
'a',
'2020-05-23 05:53:06.183 +00:00',
'2020-05-23 05:53:06.183 +00:00'
]
},
sql: 'INSERT INTO "Users" ("id","name","createdAt","updatedAt") VALUES ($1,$2,$3,$4) RETURNING "id","name","createdAt","updatedAt";'
} |
@sushantdhiman what version of node are you using? I'm kind of confused what you mean because when I tested On Node 12.16.2 I ran the following in a test and the stack trace is pretty good (except for saying await User.create({
username: 'gottlieb'
});
await User.findOrCreate({
where: {
objectId: 'asdasdasd'
},
defaults: {
username: 'gottlieb'
}
}).catch(e => console.error(e.stack)) Output
|
Okay weird...for some reason causing the error with await User.create({
username: 'gottlieb'
});
await User.create({
username: 'gottlieb'
}).catch(e => console.error(e.stack))
I'm confused why though, esp since |
Okay so I see that for Postgres at least the The code that loses the stack trace is
Maybe |
Actually I think that since the underlying |
Linking nodejs/node#11865 (comment) for reference |
Perhaps related nodejs/node#30822 |
That's funny, you discovered my comment I made while investigating this issue. I'm surprised it got so many upvotes, I thought I probably misunderstood when async stack traces are supposed to work, but maybe it really is a bug in V8. |
Upgrading to node version 14 fixed some sequelize stacktraces on my project. They now include some function calls that were missing. |
@sushantdhiman I think we've probably done everything we can in this codebase to ensure better stack traces...do you know of anything else we can improve? |
Hi @jedwards1211, I can't think of anything from the top of my head but if I do I will let you know. Again, thank you so much for the help you provided! That was great. By the way, Sushant is no longer maintaining Sequelize, I am trying to take care of things but have been really busy these days... |
Yes, this issue can be closed @jedwards1211 |
I see, yeah I don't blame either one of you. |
@jedwards1211 I don't even know what is the state of the source code right now to be honest 😅 I see some files were converted to |
🎉 This issue has been resolved in version 6.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No one wants stack traces like this, and they don't have to be this bad in recent versions of node.
The text was updated successfully, but these errors were encountered: