From b60a83c83d8d6d29f0e51622e094faea3bcdc5b3 Mon Sep 17 00:00:00 2001 From: Molly Lloyd Date: Fri, 9 Feb 2018 12:58:35 -0800 Subject: [PATCH] fix web worker error handling (#6126) --- src/util/actor.js | 4 ++-- src/util/web_worker_transfer.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/actor.js b/src/util/actor.js index b5fcdd868d3..e4cd66a2a96 100644 --- a/src/util/actor.js +++ b/src/util/actor.js @@ -69,7 +69,7 @@ class Actor { sourceMapId: this.mapId, type: '', id: String(id), - error: err ? String(err) : null, + error: err ? serialize(err) : null, data: serialize(data, buffers) }, buffers); }; @@ -78,7 +78,7 @@ class Actor { callback = this.callbacks[data.id]; delete this.callbacks[data.id]; if (callback && data.error) { - callback(new Error(data.error)); + callback(deserialize(data.error)); } else if (callback) { callback(null, deserialize(data.data)); } diff --git a/src/util/web_worker_transfer.js b/src/util/web_worker_transfer.js index d510691d4b8..9357c0f2fc5 100644 --- a/src/util/web_worker_transfer.js +++ b/src/util/web_worker_transfer.js @@ -87,6 +87,7 @@ Grid.deserialize = function deserializeGrid(serialized: ArrayBuffer): Grid { register('Grid', Grid); register('Color', Color); +register('Error', Error); register('StylePropertyFunction', StylePropertyFunction); register('StyleExpression', StyleExpression, {omit: ['_evaluator']});