Skip to content

Commit 663a3e5

Browse files
committed
Fixed async remote callbacks
1 parent 97ef39b commit 663a3e5

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/local.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ export default ({
144144
args[i] = toValue(args[i]);
145145

146146
const result = reflect(APPLY, v, toValue(this), args);
147-
/* c8 ignore start */
148-
return result instanceof Promise ? result.then(fromValue) : fromValue(result);
149-
/* c8 ignore stop */
147+
return result.then(fromValue);
150148
};
151149
wr = new WeakRef(fn);
152150
weakRefs.set(v, wr);

src/remote.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ export default ({
318318

319319
let indirect = true, direct, reference;
320320

321+
const { apply } = Reflect;
321322
const { id, ref, unref } = heap();
322323
const weakRefs = new Map;
323324
const globalTarget = tv(OBJECT, null);
@@ -407,13 +408,13 @@ export default ({
407408
* @param {...any} args
408409
* @returns
409410
*/
410-
reflect(method, uid, ...args) {
411+
reflect: async (method, uid, ...args) => {
411412
switch (method) {
412413
case APPLY: {
413414
const [context, params] = args;
414415
for (let i = 0, length = params.length; i < length; i++)
415416
params[i] = fromValue(params[i]);
416-
return toValue(Reflect.apply(ref(uid), fromValue(context), params));
417+
return toValue(await apply(ref(uid), fromValue(context), params));
417418
}
418419
case UNREF: {
419420
released(ref(uid));

types/remote.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ declare function _default({ reflect, transform, released, buffer, timeout, }?: R
4848
* @param {...any} args
4949
* @returns
5050
*/
51-
reflect(method: number, uid: number | null, ...args: any[]): any;
51+
reflect: (method: number, uid: number | null, ...args: any[]) => Promise<any>;
5252
};
5353
export default _default;
5454
/**

0 commit comments

Comments
 (0)