aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Agosti <francesco.agosti93@gmail.com>2019-01-11 01:33:22 +0800
committerGitHub <noreply@github.com>2019-01-11 01:33:22 +0800
commitbf332d578c5d229b3a8d39bf5935233ecf9526c8 (patch)
tree81a511b3e23b30445a2326940a494cc911716835
parent6c22594882c94146519ec6e3b24d558127bd092c (diff)
parentb639843115547fc3d259fcfb98599a16187b3d07 (diff)
downloaddexon-0x-contracts-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.gz
dexon-0x-contracts-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.zst
dexon-0x-contracts-bf332d578c5d229b3a8d39bf5935233ecf9526c8.zip
Merge pull request #1501 from 0xProject/fix/utils/promisify-not-accounting-for-undefined-error
[utils] account for undefined errors in promisify, not only null (and fix instant in Opera)
-rw-r--r--packages/utils/CHANGELOG.json9
-rw-r--r--packages/utils/src/promisify.ts2
2 files changed, 10 insertions, 1 deletions
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index fb85c4174..d84e32dd2 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Make `promisify` resolve when the callback error is undefined.",
+ "pr": 1501
+ }
+ ]
+ },
+ {
"version": "2.1.1",
"changes": [
{
diff --git a/packages/utils/src/promisify.ts b/packages/utils/src/promisify.ts
index 29d626b61..e82251a0f 100644
--- a/packages/utils/src/promisify.ts
+++ b/packages/utils/src/promisify.ts
@@ -10,7 +10,7 @@ export function promisify<T>(originalFn: (...args: any[]) => void, thisArg?: any
const promisifiedFunction = async (...callArgs: any[]): Promise<T> => {
return new Promise<T>((resolve, reject) => {
const callback = (err: Error | null, data?: T) => {
- _.isNull(err) ? resolve(data) : reject(err);
+ _.isNull(err) || _.isUndefined(err) ? resolve(data) : reject(err);
};
originalFn.apply(thisArg, [...callArgs, callback]);
});