Browse Source

Fix passing Promise with remote

Somehow using value.then.bind(value) would result in infinite loop,
could be bug of Chromium.
Cheng Zhao 9 years ago
parent
commit
6de9c4332f
4 changed files with 4 additions and 3 deletions
  1. 1 0
      atom/browser/auto_updater.h
  2. 1 1
      lib/browser/rpc-server.js
  3. 1 1
      lib/renderer/api/remote.js
  4. 1 1
      vendor/brightray

+ 1 - 0
atom/browser/auto_updater.h

@@ -8,6 +8,7 @@
 #include <string>
 
 #include "base/macros.h"
+#include "build/build_config.h"
 
 namespace base {
 class Time;

+ 1 - 1
lib/browser/rpc-server.js

@@ -106,7 +106,7 @@ var valueToMeta = function(sender, value, optimizeSimpleObject) {
   } else if (meta.type === 'buffer') {
     meta.value = Array.prototype.slice.call(value, 0);
   } else if (meta.type === 'promise') {
-    meta.then = valueToMeta(sender, value.then.bind(value));
+    meta.then = valueToMeta(sender, function(v) { value.then(v); });
   } else if (meta.type === 'error') {
     meta.members = plainObjectToMeta(value);
 

+ 1 - 1
lib/renderer/api/remote.js

@@ -48,7 +48,7 @@ var wrapArgs = function(args, visited) {
     } else if ((value != null ? value.constructor.name : void 0) === 'Promise') {
       return {
         type: 'promise',
-        then: valueToMeta(value.then.bind(value))
+        then: valueToMeta(function(v) { value.then(v); })
       };
     } else if ((value != null) && typeof value === 'object' && v8Util.getHiddenValue(value, 'atomId')) {
       return {

+ 1 - 1
vendor/brightray

@@ -1 +1 @@
-Subproject commit 70f475e34dd5f580dc8d5184d6fa8e5c96c5f601
+Subproject commit 7f9e25b50b373aea5e7d0a50c33aea22c85ee876