Merge pull request #18 from ziggi/rejectfix

Fix call procedure rejection with no args provided
This commit is contained in:
Micah Allen 2020-01-22 17:45:16 -05:00 committed by GitHub
commit 822679479d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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];
} }
} }