New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

odbc

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

odbc - npm Package Compare versions

Comparing version 2.4.0-beta.2 to 2.4.0-beta.3

96

lib/Pool.js

@@ -19,2 +19,3 @@ const EventEmitter = require('events');

const LOGIN_TIMEOUT_DEFAULT = 0;
const FETCH_ARRAY_DEFAULT = false;
const MAX_ACTIVELY_CONNECTING = 1;

@@ -53,3 +54,5 @@

} catch (error) {
// We don't actually do anything with errors here
// Errors are handled in the promiseGenerator through emitting a
// "connectionError" event. Error thrown and caught here simply to resolve
// the promise generated by the promiseGenerator.
}

@@ -84,19 +87,4 @@ ConnectionQueue.activelyConnectingCount--;

// returned to the user.
if (this.waitingConnectionWork.length > 0)
{
let connectionWork = this.waitingConnectionWork.shift();
let connectionWork = this.waitingConnectionWork.shift();
// If the user passed a callback function, then call the function with
// no error in the first parameter and the connection in the second
// parameter
if (typeof connectionWork == 'function')
{
return connectionWork(null, connection);
// If the user didn't pass a callback function, we returned a promise to
// them. Resolve that promise with the connection that was just created.
} else {
// Promise (stored resolve function)
return connectionWork.resolveFunction(connection);
}
// A connection finished connecting, and there was no work waiting for

@@ -106,7 +94,44 @@ // that connection to be made. Simply add it to the array of

// retrieved from there.
} else {
if (typeof connectionWork == 'undefined')
{
this.freeConnections.push(connection);
return;
}
// If the user passed a callback function, then call the function with
// no error in the first parameter and the connection in the second
// parameter
if (typeof connectionWork == 'function')
{
return connectionWork(null, connection);
}
// If the user didn't pass a callback function, we returned a promise to
// them. Resolve that promise with the connection that was just created.
// Promise (stored resolve function)
return connectionWork.resolveFunction(connection);
});
// Fires when a connection has errored. If there is no work waiting, then
// the pool will simply be empty until the next time work is requested, at
// which point there WILL be waiting work and they will get an error.
this.connectionEmitter.on('connectionError', (error) => {
let connectionWork = this.waitingConnectionWork.shift();
if (typeof connectionWork == 'undefined')
{
return;
}
// If the user passed a callback function, then call the function with
// the error in the first parameter
if (typeof connectionWork == 'function')
{
return connectionWork(error, undefined);
// If the user didn't pass a callback function, we returned a promise to
// them. Reject that promise with the generated error
} else {
// Promise (stored resolve function)
return connectionWork.rejectFunction(error);
}
});
// connectionString is a string, so use defaults for all of the

@@ -124,2 +149,3 @@ // configuration options.

this.connectionConfig.loginTimeout = LOGIN_TIMEOUT_DEFAULT;
this.connectionConfig.fetchArray = FETCH_ARRAY_DEFAULT;
}

@@ -134,2 +160,3 @@ // connectionString is an object, so ensure that connectionString is a

}
this.connectionConfig.connectionString = configObject.connectionString;

@@ -157,2 +184,5 @@

this.connectionConfig.loginTimeout = configObject.loginTimeout !== undefined ? configObject.loginTimeout : LOGIN_TIMEOUT_DEFAULT;
// fetchArray
this.connectionConfig.fetchArray = configObject.fetchArray || FETCH_ARRAY_DEFAULT;

@@ -200,9 +230,12 @@ // connectingQueueMax

let resolveConnectionPromise;
let rejectConnectionPromise;
const promise = new Promise((resolve, reject) => {
resolveConnectionPromise = resolve;
rejectConnectionPromise = reject;
});
const promiseObj = {
promise: promise,
resolveFunction: resolveConnectionPromise
resolveFunction: resolveConnectionPromise,
rejectFunction: rejectConnectionPromise,
}

@@ -328,2 +361,6 @@ // push the promise onto the waitingConnectionWork queue, then return

await this.increasePoolSize(this.initialSize);
// Try to get one connection during init to make sure there were
// no errors with the connection string
const connection = await this.connect();
this.freeConnections.unshift(connection);
resolve();

@@ -339,2 +376,4 @@ } catch (error) {

await this.increasePoolSize(this.initialSize);
connection = await this.connect();
connection.close();
} catch (error) {

@@ -352,2 +391,21 @@ return callback(error);

if (error) {
// When there is a connection error, emit a "connectionError" event
// with the error that is then either handled by any waiting work, or
// is silently swallowed if no work is waiting. This is so that a bad
// attempt at connecting doesn't throw an uncatchable error when there
// is no user work, crashing the entire application.
//
// Catchable errors occur:
// 1. When a pool is initialized and there was a problem with the
// first connection (no network, bad connection string, etc.)
// 2. When a user is attempting to do work and there are no active
// connections, the pool will attempt to connect, emit the error, and
// send it to the user work that was waiting (either as an error
// parameter in the user's callback, or as a thrown error that the
// user has to catch.)
this.pool.connectionEmitter.emit('connectionError', error);
// This reject is swallowed in the ConnectionQueue's dequeue function
// in all cases, and is simply to end the Promise that was generated
// by generateConnectPromise.
reject(error);

@@ -354,0 +412,0 @@ return;

2

package.json
{
"name": "odbc",
"description": "unixodbc bindings for node",
"version": "2.4.0-beta.2",
"version": "2.4.0-beta.3",
"homepage": "http://github.com/markdirish/node-odbc/",

@@ -6,0 +6,0 @@ "main": "lib/odbc.js",

@@ -17,2 +17,3 @@ # odbc

* using brew `brew install unixODBC`
* on FreeBSD from ports `cd /usr/ports/databases/unixODBC; make install`
* on IBM i `yum install unixODBC unixODBC-devel` (requires [yum](http://ibm.biz/ibmi-rpms))

@@ -45,2 +46,3 @@ * ODBC drivers for target database

* **using brew:** `brew install unixODBC`
* **FreeBSD** from ports: `cd /usr/ports/databases/unixODBC; make install`
* **IBM i:** `yum install unixODBC unixODBC-devel` (requires [yum](http://ibm.biz/ibmi-rpms))

@@ -47,0 +49,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc