diff --git a/atom/browser/lib/rpc-server.coffee b/atom/browser/lib/rpc-server.coffee index ab86a0c45518..d1e3267784e5 100644 --- a/atom/browser/lib/rpc-server.coffee +++ b/atom/browser/lib/rpc-server.coffee @@ -10,6 +10,7 @@ valueToMeta = (sender, value) -> meta.type = 'buffer' if Buffer.isBuffer value meta.type = 'value' if value is null meta.type = 'array' if Array.isArray value + meta.type = 'promise' if Promise.resolve(value) == value # Treat the arguments object as array. meta.type = 'array' if meta.type is 'object' and value.callee? and value.length? @@ -29,6 +30,8 @@ valueToMeta = (sender, value) -> meta.members.push {name: prop, type: typeof field} for prop, field of value else if meta.type is 'buffer' meta.value = Array::slice.call value, 0 + else if meta.type is 'promise' + meta.then = valueToMeta(sender, value.then.bind(value)) else meta.type = 'value' meta.value = value diff --git a/atom/renderer/api/lib/remote.coffee b/atom/renderer/api/lib/remote.coffee index b159125b7949..5ad7c80ca01f 100644 --- a/atom/renderer/api/lib/remote.coffee +++ b/atom/renderer/api/lib/remote.coffee @@ -44,6 +44,7 @@ metaToValue = (meta) -> when 'value' then meta.value when 'array' then (metaToValue(el) for el in meta.members) when 'buffer' then new Buffer(meta.value) + when 'promise' then Promise.resolve(then: metaToValue(meta.then)) when 'error' throw new Error("#{meta.message}\n#{meta.stack}") else