-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
mssql.connect generates error "socket must be an instance of net.Socket" / node:tls
does not accept a custom stream for it's .socket
param
#5147
Comments
Also reproduced on bun 1.0.2 with correct user name and password, thus making it impossible to use bun with mssql. |
same issue :(( |
Same issue here connecting to Azure SQL Server with sequelize. |
Same issue here connecting to Azure SQL Server with sequelize !!! |
Same error. Can connect to the Azure service just fine from the same local machine with Visual Code + the SQL server plugin. Firewall rules allow access. Bun + Knex fails to connect with the same config/env vars and throws a |
I had the same problem, it was not possible to connect to the SQL SERVER. After updating to Bun 1.0.6, it apparently worked! I'll do some more testing but it's possible that the team has already fixed the lack of net.Socket implementation. Steps: bun init . # confirm, confirm ...
bun add mssql
bun add knex ./index.ts import knex from "knex";
const db = knex({
client: "mssql",
connection: {
host: Bun.env["DB_DEV_HOST"],
port: parseInt(Bun.env["DB_DEV_PORT"] || "1433"),
user: Bun.env["DB_USER"],
password: Bun.env["DB_PASS"],
database: Bun.env["DB_DATABASE"],
},
});
console.log(await db.table("example_table").first()); ./package.json {
"name": "bot-bun",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"knex": "^3.0.1",
"mssql": "^10.0.1"
}
}
|
It is still an issue with bun 1.0.11 Anyone found a fix? |
Same error in macOS sonoma. Everything works properly in node |
I am on Bun v1.0.20, and I am also getting this error when trying to connect to a MS SQL Server database using This seems to me to be a pretty big deal. Having no ability to connect to databases from a runtime that's suppose to run on servers, one of the most common things you would ever do on a server. Is there possibly some other configuration needed to get this working? |
Can we get an update on this, how can bun be viable without even basic sql driver support? |
It looks like the issue is that our version of
|
dependency-free reproduction
|
node:tls
does not accept a non-tls socket
node:tls
does not accept a non-tls socketnode:tls
does not accept a custom stream for it's .socket
param
We need to connect to a sqlserver database using node-mssql, it would be really good to be able to use bun at work. Please keep up the good work |
I recently came across this exact scenario and tried a number of things. Initially I tried just using I suspected it might be a Then, upgrading to latest packages AND wrapping with
|
Same issue on our side,
We have an existing project we wanna migrate to bun. But this issue makes it completely impossible, reworking our full code base to use knex or maybe try prisma will take to long. Developers needs to look into this issue... This really makes bun in my eyes useless. Databases are somewhat important. |
I am also getting blocked by this issue:
Seconding @mvandervliet that Knex functions. We have an older project that we don't want to convert, so being able to use sequelize and tedious out of the box would be much nicer. |
Same issue here bun: 1.0.35 I need a fix for this issue to continue migrating to Bun. |
Still exists Bun: 1.1.6 |
Still exists Bun: 1.1.17 import sql from 'mssql';
try {
await sql.connect('Server=.;Database=kysely_rnd;Trusted_Connection=True;Encrypt=true')
const result = await sql.query`select * from kysely_rnd `
console.dir(result)
} catch (err) {
console.log(err)
} Error: bun .\src\mssql.ts
80 | rejectOnce(err)
81 | return
82 | }
83 | tedious.connect(err => {
84 | if (err) {
85 | err = new ConnectionError(err)
^
ConnectionError: Failed to connect to localhost:1433 - socket must be an instance of net.Socket
code: "ESOCKET"
at with-db\node_modules\mssql\lib\tedious\connection-pool.js:85:17
at onConnect (with-db\node_modules\tedious\lib\connection.js:1337:7)
at native:1:1
at emit (native:1:1)
at socketError (with-db\node_modules\tedious\lib\connection.js:2133:7)
at with-db\node_modules\tedious\lib\connection.js:2238:25
at processTicksAndRejections (native:1:1) |
Is there any roadmap on when will this be prioritized? The reality is that It would be great to at least get an information on if it's planned to be addressed any soon or it's treated a low prio thing. |
same issue here, also interested in knowing if is there any roadmap taking this (very blocking) issue in consideration |
same here, this is a showstoper for us. |
Unsecure workaround:bun: 1.1.18 I'm running SQL Server 2022 on localhost (on Linux) and I can do without TLS encryption.
Then you need to disable client encryption in the tedious connection config (encrypt: false):
That worked for me. |
I have the same issue in Bun 1.1.20.
is this PR going to fix it? #12750 |
Any updates on this error? I tested it again in version 1.1.21, and the issue still persists. It's a shame because it's a product with a lot of potential, but without resolving these kinds of errors, using Bun loses its purpose. |
maybe you can try for update database config |
Not only it makes it less secure, but also it's completely unacceptable for azure, as it prevents you from editing the encryption settings on the db, enforcing encryption. |
I hope that one day this will be resolved 😭 |
@Necrelox the day has come. The fix for this will be part of Bun v1.1.27, which ships in about an hour |
@Jarred-Sumner Wow, I'm so happy ! Thank you so much !!!! |
@Jarred-Sumner I am still experiencing the same ESOCKET issue error Log PS C:\Users\> bun .\src\index.js
80 | rejectOnce(err)
81 | return
82 | }
83 | tedious.connect(err => {
84 | if (err) {
85 | err = new ConnectionError(err)
^
ConnectionError: Connection lost - socket hang up
code: "ESOCKET"
at C:\Users\dsacco\ts-project\node_modules\mssql\lib\tedious\connection-pool.js:85:17
at onError (C:\Users\dsacco\ts-project\node_modules\tedious\lib\connection.js:853:9)
at onceWrapper (node:events:38:55)
at emitError (node:events:14:19)
at socketError (C:\Users\dsacco\ts-project\node_modules\tedious\lib\connection.js:1359:12)
at socketEnd (C:\Users\dsacco\ts-project\node_modules\tedious\lib\connection.js:1374:12)
at C:\Users\dsacco\ts-project\node_modules\tedious\lib\connection.js:1066:12
at emit (node:events:278:22)
at endReadableNT (node:stream:2402:47)
Bun v1.1.41 (Windows x64) Index.js File import sql from 'mssql';
import dotenv from 'dotenv';
dotenv.config();
const config = {
user: process.env.Sql_Username,
password: process.env.Sql_Password,
server: process.env.Sql_Server,
options: {
encrypt: true,
trustServerCertificate: true,
idleTimeoutMillis: 300000,
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 300000,
},
};
const connection = await sql.connect(config);
const result = await connection.query`use msm101 select top(1) * from history`;
console.log(result.recordset);
sql.close(); but if i run the exact same code using the node command |
What version of Bun is running?
1.0.1+31aec4ebe325982fc0ef27498984b0ad9969162b
What platform is your computer?
Darwin 21.6.0 x86_64 i386
What steps can reproduce the bug?
Create a file named index.js with the following contents:
You can literally use that example server to reproduce. No need to set up your own SQL Server.
What is the expected behavior?
Connection error because the user/password is wrong:
ConnectionError: Cannot open server 'example' requested by the login. Client with IP address '136.38.114.139' is not allowed to access the server...
I am checking this by running the same file with node 20.5.0.
Of course in my real code, I can also connect to my server successfully, but I don't want to share my DB host publicly, so this was a more minimal reproduction I could share.
What do you see instead?
ConnectionError: Failed to connect to example.database.windows.net:1433 - socket must be an instance of net.Socket
code: "ESOCKET"
Additional information
I think the error is thrown here:
bun/src/js/node/net.js
Line 437 in 4c113d1
But I haven't been able to figure out what line in mssql lib is triggering this.
The text was updated successfully, but these errors were encountered: