From 1c44f333ce4bb155c0c40eaf4b1fa5a88a1c3d17 Mon Sep 17 00:00:00 2001 From: wanglihui Date: Thu, 28 Sep 2017 17:58:11 +0800 Subject: [PATCH 1/2] fixed error@context serailize error --- context.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/context.js b/context.js index e729e45..03d2da9 100644 --- a/context.js +++ b/context.js @@ -49,8 +49,13 @@ Namespace.prototype.run = function (fn) { return context; } catch (exception) { - if (exception) { - exception[ERROR_SYMBOL] = context; + if (exception && !exception[ERROR_SYMBOL]) { + Object.defineProperty(exception, ERROR_SYMBOL, { + configurable: true, + enumerable: false, + writable: false, + value: context + }); } throw exception; } @@ -84,8 +89,13 @@ Namespace.prototype.bind = function (fn, context) { return fn.apply(this, arguments); } catch (exception) { - if (exception) { - exception[ERROR_SYMBOL] = context; + if (exception && !exception[ERROR_SYMBOL]) { + Object.defineProperty(exception, ERROR_SYMBOL, { + configurable: true, + enumerable: false, + writable: false, + value: context + }); } throw exception; } From 46c90f103927937a17d57f3c0ed21ecfd82d35a7 Mon Sep 17 00:00:00 2001 From: wanglihui Date: Thu, 28 Dec 2017 11:39:50 +0800 Subject: [PATCH 2/2] fixed test error --- test/crypto.tap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/crypto.tap.js b/test/crypto.tap.js index 38426e5..bcd2cd6 100644 --- a/test/crypto.tap.js +++ b/test/crypto.tap.js @@ -60,7 +60,7 @@ if (crypto) { t.test("deflate", function (t) { namespace.run(function () { namespace.set('test', 42); - crypto.pbkdf2("s3cr3tz", "451243", 10, 40, function (err) { + crypto.pbkdf2("s3cr3tz", "451243", 10, 40, 'sha512', function (err) { if (err) throw err; t.equal(namespace.get('test'), 42, "mutated state was preserved"); t.end();