fix(mysql): only unreference connections in a Bun environment as it has problems with Node for some reason
This commit is contained in:
parent
98e3ed5c1b
commit
17feb2d2c2
4 changed files with 26 additions and 9 deletions
5
.changeset/sharp-houses-smell.md
Normal file
5
.changeset/sharp-houses-smell.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@emigrate/mysql': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Only unreference connections in a Bun environment as it crashes Node for some reason, without even throwing an error that is
|
||||||
|
|
@ -43,7 +43,9 @@
|
||||||
"mysql2": "3.6.5"
|
"mysql2": "3.6.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emigrate/tsconfig": "workspace:*"
|
"@emigrate/tsconfig": "workspace:*",
|
||||||
|
"@types/bun": "1.0.5",
|
||||||
|
"bun-types": "1.0.26"
|
||||||
},
|
},
|
||||||
"volta": {
|
"volta": {
|
||||||
"extends": "../../package.json"
|
"extends": "../../package.json"
|
||||||
|
|
|
||||||
|
|
@ -171,11 +171,13 @@ export const createMysqlStorage = ({ table = defaultTable, connection }: MysqlSt
|
||||||
async initializeStorage() {
|
async initializeStorage() {
|
||||||
const pool = getPool(connection);
|
const pool = getPool(connection);
|
||||||
|
|
||||||
pool.on('connection', (connection) => {
|
if (process.isBun) {
|
||||||
// @ts-expect-error stream is not in the types but it's there
|
pool.on('connection', (connection) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
// @ts-expect-error stream is not in the types but it's there
|
||||||
connection.stream.unref();
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
});
|
connection.stream.unref();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await pool.query('SELECT 1');
|
await pool.query('SELECT 1');
|
||||||
|
|
||||||
|
|
@ -274,9 +276,11 @@ export const createMysqlLoader = ({ connection }: MysqlLoaderOptions): LoaderPlu
|
||||||
const contents = await fs.readFile(migration.filePath, 'utf8');
|
const contents = await fs.readFile(migration.filePath, 'utf8');
|
||||||
const conn = await getConnection(connection);
|
const conn = await getConnection(connection);
|
||||||
|
|
||||||
// @ts-expect-error the connection is not in the types but it's there
|
if (process.isBun) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
// @ts-expect-error the connection is not in the types but it's there
|
||||||
conn.connection.stream.unref();
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
conn.connection.stream.unref();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await conn.query(contents);
|
await conn.query(contents);
|
||||||
|
|
|
||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
|
|
@ -130,6 +130,12 @@ importers:
|
||||||
'@emigrate/tsconfig':
|
'@emigrate/tsconfig':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../tsconfig
|
version: link:../tsconfig
|
||||||
|
'@types/bun':
|
||||||
|
specifier: 1.0.5
|
||||||
|
version: 1.0.5
|
||||||
|
bun-types:
|
||||||
|
specifier: 1.0.26
|
||||||
|
version: 1.0.26
|
||||||
|
|
||||||
packages/plugin-generate-js:
|
packages/plugin-generate-js:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue