Comments (6)
I'm not seeing any uncaught exception errors in the log, so it's unclear what's actually crashing the server.
@igalklebanov Any ideas? Could it be we're not listening to the error
event and it "leaks out"?
from kysely.
I think this is something Kysely should do automatically
from kysely.
@koskimas @AnthonyPhan Yeah, haven't handled this one by mistake. Let's do it.
from kysely.
Are you absolutely sure you don't have some call somewhere without an exception handler? The stack trace shows the error comes all the way up to the execute
method. After that it's just a standard Promise
. We don't do anything special there. I don't see how this could be caused by Kysely.
Try converting all kysely calls to await
syntax. That way you get the stack trace all the way up to your own code.
from kysely.
Hi @koskimas
Thanks for pointer. I went back over the code base to check for instances of execute() without a catch and did find a few, this was the cause of the error above.
However after I ensure a .catch
on all instance of execute()
i'm still able to crash the node serve by toggling the SQL db off and on. Im not sure if this is actually due to Kysely however i've attached an error log below incase you can spot the issue.
/Users/anthonyphan/repos/nex-gps/node_modules/tedious/src/connection.ts:2313
this.emit('error', new ConnectionError(message, 'ESOCKET'));
^
ConnectionError: Connection lost - socket hang up
at Connection.socketError (/Users/anthonyphan/repos/nex-gps/node_modules/tedious/src/connection.ts:2313:26)
at Connection.socketEnd (/Users/anthonyphan/repos/nex-gps/node_modules/tedious/src/connection.ts:2326:12)
at Socket.<anonymous> (/Users/anthonyphan/repos/nex-gps/node_modules/tedious/src/connection.ts:1997:35)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ESOCKET'
}
[nodemon] app crashed - waiting for file changes before starting...
from kysely.
I think i might have resolved the issue by creating the the dialect as show below with the error handler. Unsure if this is classed as user error or if the Kysely library should of caught that error. Either way i'm happy that we got to the bottom of it :) Appreciate the help!
import { Database } from './types.ts' // this is the Database interface we defined earlier
import * as tedious from 'tedious'
import * as tarn from 'tarn'
import { Kysely, MssqlDialect } from 'kysely'
const dialect = new MssqlDialect({
tarn: {
...tarn,
options: {
min: 0,
max: 10,
},
},
tedious: {
...tedious,
connectionFactory: () => new tedious.Connection({
authentication: {
options: {
password: 'password',
userName: 'username',
},
type: 'default',
},
options: {
database: 'some_db',
port: 1433,
trustServerCertificate: true,
},
server: 'localhost',
}).on('error', console.log), //THIS LINE RESOLVES THE ISSUE
},
})
// Database interface is passed to Kysely's constructor, and from now on, Kysely
// knows your database structure.
// Dialect is passed to Kysely's constructor, and from now on, Kysely knows how
// to communicate with your database.
export const db = new Kysely<Database>({
dialect,
})
from kysely.
Related Issues (20)
- Postgres migrateUp sometimes failing if migration name has a "-" character HOT 2
- syntax error at or near "returning" with vercel postgres database HOT 3
- Fix: Mssql introspection duplicate columns
- Add limit method for UpdateQueryBuilder
- JSON select types are working incorrectly with zod passthrough object HOT 5
- Compile time checks for empty arrays HOT 2
- Incorrect types and missing suggestions when using object index signature HOT 2
- UUID doesn't seem to work for inserts (Postgres) HOT 1
- Loose typechecking on innerJoin/leftJoin comparisons HOT 2
- TypeChecking for doUpdateSet not working since 0.27.0 HOT 3
- Support "using" in joins
- [Q] Reusable CTE (psql) HOT 1
- Issue with parentheses in Postgres using a conflict expression HOT 1
- Query execution result type always resolves to an empty object i.e. "{}" HOT 2
- camelCase plugin is not being applied to subquery results that incorporates jsonArrayFrom HOT 3
- Streaming results not working on Deno for PostgreSQL HOT 2
- Case of extremely slow type checking HOT 4
- ParseJSONResultsPlugin HOT 1
- `INCLUDE` clause in Postgres `createIndex`
- Pass client instance HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kysely.