Fix call procedure rejection with no args provided

This commit is contained in:
ziggi 2020-01-21 21:14:10 +03:00
parent 73ba272497
commit 0db97851cd

View File

@ -55,13 +55,13 @@ if(!glob[PROCESS_EVENT]){
} }
if(ret){ if(ret){
const promise = callProcedure(data.name, data.args, info); const promise = callProcedure(data.name, data.args, info);
if(!data.noRet) promise.then(res => ret({ ...part, res })).catch(err => ret({ ...part, err })); if(!data.noRet) promise.then(res => ret({ ...part, res })).catch(err => ret({ ...part, err: err ? err : null }));
} }
}else if(data.ret){ // a previously called remote procedure has returned }else if(data.ret){ // a previously called remote procedure has returned
const info = glob.__rpcPending[data.id]; const info = glob.__rpcPending[data.id];
if(environment === "server" && info.player !== player) return; if(environment === "server" && info.player !== player) return;
if(info){ if(info){
info.resolve(data.err ? util.promiseReject(data.err) : util.promiseResolve(data.res)); info.resolve(data.hasOwnProperty('err') ? util.promiseReject(data.err) : util.promiseResolve(data.res));
delete glob.__rpcPending[data.id]; delete glob.__rpcPending[data.id];
} }
} }