Description
Okay I know this sounds super weird, bear with me.
We just started migrating from jest to vitest in our codebase.
The machines would just hang in the CI when running them. I couldn't for the life of me figure out why.
After a lot of trial and error I narrowed it down to 1 thing.
If I pass a typeCast (empty, just calling next()
)=> Tests run fine everything is good
If I don't pass a typeCast => Tests hangs in CI and I can see a good extra consistent 10s additional teardown (from 7s to 17s to run a few files)
I suspect vitest doesn't like something here
node-mysql2/lib/parsers/text_parser.js
Lines 168 to 181 in 949353a
This is likely a vitest specific issue, but any insights I could get here would go a long way to help me open up an issue on their side to investigate.
Note: We're still on 2.3.3, but I confirmed the issue still happens on latest 3.6.1
For reference here's the parser with typecast and without
With typeCast
(function anonymous(wrap
) {
return ((function () {
return class TextRow {
constructor(fields) {
const _this = this;
for(let i=0; i<fields.length; ++i) {
this[`wrap${i}`] = wrap(fields[i], _this);
}
}
next(packet, fields, options) {
this.packet = packet;
const result = {};
// "id": LONG
result["id"] = options.typeCast(this.wrap0, function() { return packet.parseLengthCodedIntNoBigCheck() });
// "auth_type": STRING
result["auth_type"] = options.typeCast(this.wrap1, function() { return packet.readLengthCodedString(fields[1].encoding) });
// "phone_number": VAR_STRING
result["phone_number"] = options.typeCast(this.wrap2, function() { return packet.readLengthCodedString(fields[2].encoding) });
// "email": VAR_STRING
result["email"] = options.typeCast(this.wrap3, function() { return packet.readLengthCodedString(fields[3].encoding) });
// "first_name": VAR_STRING
result["first_name"] = options.typeCast(this.wrap4, function() { return packet.readLengthCodedString(fields[4].encoding) });
// "last_name": VAR_STRING
result["last_name"] = options.typeCast(this.wrap5, function() { return packet.readLengthCodedString(fields[5].encoding) });
// "img": VAR_STRING
result["img"] = options.typeCast(this.wrap6, function() { return packet.readLengthCodedString(fields[6].encoding) });
// "created_at": TIMESTAMP
result["created_at"] = options.typeCast(this.wrap7, function() { return packet.parseDateTime('local') });
// "updated_at": TIMESTAMP
result["updated_at"] = options.typeCast(this.wrap8, function() { return packet.parseDateTime('local') });
// "activated_at": DATETIME
result["activated_at"] = options.typeCast(this.wrap9, function() { return packet.parseDateTime('local') });
// "last_visited_at": DATETIME
result["last_visited_at"] = options.typeCast(this.wrap10, function() { return packet.parseDateTime('local') });
// "last_invite_sent_at": DATETIME
result["last_invite_sent_at"] = options.typeCast(this.wrap11, function() { return packet.parseDateTime('local') });
return result;
}
};
})())
})
Without typeCast
(function anonymous(
) {
return ((function () {
return class TextRow {
constructor(fields) {
}
next(packet, fields, options) {
this.packet = packet;
const result = {};
// "id": LONG
result["id"] = packet.parseLengthCodedIntNoBigCheck();
// "auth_type": STRING
result["auth_type"] = packet.readLengthCodedString(fields[1].encoding);
// "phone_number": VAR_STRING
result["phone_number"] = packet.readLengthCodedString(fields[2].encoding);
// "email": VAR_STRING
result["email"] = packet.readLengthCodedString(fields[3].encoding);
// "first_name": VAR_STRING
result["first_name"] = packet.readLengthCodedString(fields[4].encoding);
// "last_name": VAR_STRING
result["last_name"] = packet.readLengthCodedString(fields[5].encoding);
// "img": VAR_STRING
result["img"] = packet.readLengthCodedString(fields[6].encoding);
// "created_at": TIMESTAMP
result["created_at"] = packet.parseDateTime('local');
// "updated_at": TIMESTAMP
result["updated_at"] = packet.parseDateTime('local');
// "activated_at": DATETIME
result["activated_at"] = packet.parseDateTime('local');
// "last_visited_at": DATETIME
result["last_visited_at"] = packet.parseDateTime('local');
// "last_invite_sent_at": DATETIME
result["last_invite_sent_at"] = packet.parseDateTime('local');
return result;
}
};
})())
})