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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@emigrate/tsconfig": "workspace:*"
|
||||
"@emigrate/tsconfig": "workspace:*",
|
||||
"@types/bun": "1.0.5",
|
||||
"bun-types": "1.0.26"
|
||||
},
|
||||
"volta": {
|
||||
"extends": "../../package.json"
|
||||
|
|
|
|||
|
|
@ -171,11 +171,13 @@ export const createMysqlStorage = ({ table = defaultTable, connection }: MysqlSt
|
|||
async initializeStorage() {
|
||||
const pool = getPool(connection);
|
||||
|
||||
pool.on('connection', (connection) => {
|
||||
// @ts-expect-error stream is not in the types but it's there
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
connection.stream.unref();
|
||||
});
|
||||
if (process.isBun) {
|
||||
pool.on('connection', (connection) => {
|
||||
// @ts-expect-error stream is not in the types but it's there
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
connection.stream.unref();
|
||||
});
|
||||
}
|
||||
|
||||
await pool.query('SELECT 1');
|
||||
|
||||
|
|
@ -274,9 +276,11 @@ export const createMysqlLoader = ({ connection }: MysqlLoaderOptions): LoaderPlu
|
|||
const contents = await fs.readFile(migration.filePath, 'utf8');
|
||||
const conn = await getConnection(connection);
|
||||
|
||||
// @ts-expect-error the connection is not in the types but it's there
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
conn.connection.stream.unref();
|
||||
if (process.isBun) {
|
||||
// @ts-expect-error the connection is not in the types but it's there
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
conn.connection.stream.unref();
|
||||
}
|
||||
|
||||
try {
|
||||
await conn.query(contents);
|
||||
|
|
|
|||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
|
|
@ -130,6 +130,12 @@ importers:
|
|||
'@emigrate/tsconfig':
|
||||
specifier: workspace:*
|
||||
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:
|
||||
dependencies:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue