Skip to content

Commit 2502b1b

Browse files
committed
fix: remove unnecessary bluebird usage
1 parent 0b07db2 commit 2502b1b

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

README.md

+3-25
Original file line numberDiff line numberDiff line change
@@ -919,16 +919,7 @@ redis.set('foo', function (err) {
919919
});
920920
```
921921

922-
When a reply error is not handled (no callback is specified, and no `catch` method is chained),
923-
the error will be logged to stderr. For instance:
924-
925-
```javascript
926-
var Redis = require('ioredis');
927-
var redis = new Redis();
928-
redis.set('foo');
929-
```
930-
931-
The following error will be printed:
922+
This is the error stack of the `ReplyError`:
932923

933924
```
934925
Unhandled rejection ReplyError: ERR wrong number of arguments for 'set' command
@@ -941,7 +932,7 @@ Unhandled rejection ReplyError: ERR wrong number of arguments for 'set' command
941932
at TCP.onread (net.js:509:20)
942933
```
943934

944-
But the error stack doesn't make any sense because the whole stack happens in the ioredis
935+
By default, the error stack doesn't make any sense because the whole stack happens in the ioredis
945936
module itself, not in your code. So it's not easy to find out where the error happens in your code.
946937
ioredis provides an option `showFriendlyErrorStack` to solve the problem. When you enable
947938
`showFriendlyErrorStack`, ioredis will optimize the error stack for you:
@@ -955,7 +946,7 @@ redis.set('foo');
955946
And the output will be:
956947

957948
```
958-
Unhandled rejection ReplyError: ERR wrong number of arguments for 'set' command
949+
ReplyError: ERR wrong number of arguments for 'set' command
959950
at Object.<anonymous> (/app/index.js:3:7)
960951
at Module._compile (module.js:446:26)
961952
at Object.Module._extensions..js (module.js:464:10)
@@ -970,19 +961,6 @@ This time the stack tells you that the error happens on the third line in your c
970961
However, it would decrease the performance significantly to optimize the error stack. So by
971962
default, this option is disabled and can only be used for debugging purposes. You **shouldn't** use this feature in a production environment.
972963

973-
If you want to catch all unhandled errors without decreased performance, there's another way:
974-
975-
```javascript
976-
var Redis = require('ioredis');
977-
Redis.Promise.onPossiblyUnhandledRejection(function (error) {
978-
// you can log the error here.
979-
// error.command.name is the command name, here is 'set'
980-
// error.command.args is the command arguments, here is ['foo']
981-
});
982-
var redis = new Redis();
983-
redis.set('foo');
984-
```
985-
986964
# Plugging in your own Promises Library
987965
If you're an advanced user, you may want to plug in your own promise library like [bluebird](https://www.npmjs.com/package/bluebird). Just set Redis.Promise to your favorite ES6-style promise constructor and ioredis will use it.
988966

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
exports = module.exports = require('./lib/redis');
44

55
exports.ReplyError = require('./lib/reply_error');
6-
exports.Promise = require('bluebird');
76
exports.Cluster = require('./lib/cluster');
87
exports.Command = require('./lib/command');
98

0 commit comments

Comments
 (0)