You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
chore: use short handle for process.nextTick
This commit is contained in:
6
index.js
6
index.js
@@ -67,8 +67,10 @@ function RedisClient (options, stream) {
|
|||||||
options.detectBuffers = !!options.detectBuffers
|
options.detectBuffers = !!options.detectBuffers
|
||||||
// Override the detectBuffers setting if returnBuffers is active and print a warning
|
// Override the detectBuffers setting if returnBuffers is active and print a warning
|
||||||
if (options.returnBuffers && options.detectBuffers) {
|
if (options.returnBuffers && options.detectBuffers) {
|
||||||
process.nextTick(() =>
|
process.nextTick(
|
||||||
utils.warn(this, 'WARNING: You activated returnBuffers and detectBuffers at the same time. The return value is always going to be a buffer.')
|
utils.warn,
|
||||||
|
this,
|
||||||
|
'WARNING: You activated returnBuffers and detectBuffers at the same time. The return value is always going to be a buffer.'
|
||||||
)
|
)
|
||||||
options.detectBuffers = false
|
options.detectBuffers = false
|
||||||
}
|
}
|
||||||
|
@@ -57,14 +57,14 @@ function readyHandler (client) {
|
|||||||
if (!client.closing) {
|
if (!client.closing) {
|
||||||
// TODO: These internal things should be wrapped in a
|
// TODO: These internal things should be wrapped in a
|
||||||
// special error that describes what is happening
|
// special error that describes what is happening
|
||||||
process.nextTick(() => client.emit('error', err))
|
process.nextTick(client.emit, 'error', err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (client.monitoring) { // Monitor has to be fired before pub sub commands
|
if (client.monitoring) { // Monitor has to be fired before pub sub commands
|
||||||
client.internalSendCommand(new Command('monitor', [])).catch((err) => {
|
client.internalSendCommand(new Command('monitor', [])).catch((err) => {
|
||||||
if (!client.closing) {
|
if (!client.closing) {
|
||||||
process.nextTick(() => client.emit('error', err))
|
process.nextTick(client.emit, 'error', err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ function readyHandler (client) {
|
|||||||
const args = client.subscriptionSet[key]
|
const args = client.subscriptionSet[key]
|
||||||
client[command]([args]).catch((err) => {
|
client[command]([args]).catch((err) => {
|
||||||
if (!client.closing) {
|
if (!client.closing) {
|
||||||
process.nextTick(() => client.emit('error', err))
|
process.nextTick(client.emit, 'error', err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -103,9 +103,7 @@ function replyInOrder (client, callback, err, res, queue) {
|
|||||||
commandObj = client.offlineQueue.peekBack() || client.commandQueue.peekBack()
|
commandObj = client.offlineQueue.peekBack() || client.commandQueue.peekBack()
|
||||||
}
|
}
|
||||||
if (!commandObj) {
|
if (!commandObj) {
|
||||||
process.nextTick(() => {
|
process.nextTick(callback, err, res)
|
||||||
callback(err, res)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
const tmp = commandObj.callback
|
const tmp = commandObj.callback
|
||||||
commandObj.callback = function (e, r) {
|
commandObj.callback = function (e, r) {
|
||||||
|
@@ -127,9 +127,7 @@ describe('connection tests', () => {
|
|||||||
client.once('ready', () => {
|
client.once('ready', () => {
|
||||||
client.set('foo', 'bar').catch(helper.isError())
|
client.set('foo', 'bar').catch(helper.isError())
|
||||||
client.quit().then(() => done())
|
client.quit().then(() => done())
|
||||||
process.nextTick(() => {
|
process.nextTick(() => client._stream.destroy())
|
||||||
client._stream.destroy()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -288,9 +286,7 @@ describe('connection tests', () => {
|
|||||||
client = redis.createClient({
|
client = redis.createClient({
|
||||||
connectTimeout: 1000
|
connectTimeout: 1000
|
||||||
})
|
})
|
||||||
process.nextTick(() => {
|
process.nextTick(assert.strictEqual, client._stream._idleTimeout, 1000)
|
||||||
assert.strictEqual(client._stream._idleTimeout, 1000)
|
|
||||||
})
|
|
||||||
client.on('connect', () => {
|
client.on('connect', () => {
|
||||||
assert.strictEqual(client._stream._idleTimeout, -1)
|
assert.strictEqual(client._stream._idleTimeout, -1)
|
||||||
assert.strictEqual(client._stream.listeners('timeout').length, 0)
|
assert.strictEqual(client._stream.listeners('timeout').length, 0)
|
||||||
|
@@ -207,6 +207,6 @@ module.exports = {
|
|||||||
family: 4
|
family: 4
|
||||||
}
|
}
|
||||||
client.address = '127.0.0.1:65535'
|
client.address = '127.0.0.1:65535'
|
||||||
client._stream.destroy()
|
process.nextTick(() => client._stream.destroy())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,7 @@ client.set('foo').catch((err) => {
|
|||||||
assert(/good-traces.js:9:8/.test(err.stack))
|
assert(/good-traces.js:9:8/.test(err.stack))
|
||||||
client.set('foo', 'bar').catch((err) => {
|
client.set('foo', 'bar').catch((err) => {
|
||||||
assert(/good-traces.js:11:10/.test(err.stack))
|
assert(/good-traces.js:11:10/.test(err.stack))
|
||||||
client.quit(() => {
|
client.quit(() => process.exit(0))
|
||||||
process.exit(0)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
process.nextTick(() => {
|
|
||||||
client._stream.destroy()
|
|
||||||
})
|
})
|
||||||
|
process.nextTick(() => client._stream.destroy())
|
||||||
})
|
})
|
||||||
|
@@ -476,12 +476,10 @@ describe('The nodeRedis client', () => {
|
|||||||
assert(err instanceof redis.InterruptError)
|
assert(err instanceof redis.InterruptError)
|
||||||
error = err.origin
|
error = err.origin
|
||||||
})
|
})
|
||||||
// Make sure we call execute out of the reply
|
// Make sure we call execute out of the reply.
|
||||||
// ready is called in a reply
|
// Ready is called in a reply.
|
||||||
process.nextTick(() => {
|
// Fail the set answer. Has no corresponding command obj and will therefore land in the error handler and set
|
||||||
// Fail the set answer. Has no corresponding command obj and will therefore land in the error handler and set
|
process.nextTick(() => client._replyParser.execute(Buffer.from('a*1\r*1\r$1`zasd\r\na')))
|
||||||
client._replyParser.execute(Buffer.from('a*1\r*1\r$1`zasd\r\na'))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user