mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
Add asserts checking that async ops return null (#2463)
This commit is contained in:
parent
d60bdb6350
commit
8ec5276d30
1 changed files with 4 additions and 3 deletions
|
@ -91,7 +91,7 @@ export function sendAsync(
|
|||
data,
|
||||
false
|
||||
);
|
||||
util.assert(response == null);
|
||||
util.assert(response == null); // null indicates async.
|
||||
const promise = util.createResolvable<msg.Base>();
|
||||
promiseTable.set(cmdId, promise);
|
||||
return promise;
|
||||
|
@ -106,10 +106,11 @@ export function sendSync(
|
|||
): null | msg.Base {
|
||||
const [cmdId, response] = sendInternal(builder, innerType, inner, data, true);
|
||||
util.assert(cmdId >= 0);
|
||||
if (response == null || response.length === 0) {
|
||||
util.assert(response != null); // null indicates async.
|
||||
if (response!.length === 0) {
|
||||
return null;
|
||||
} else {
|
||||
const bb = new flatbuffers.ByteBuffer(response);
|
||||
const bb = new flatbuffers.ByteBuffer(response!);
|
||||
const baseRes = msg.Base.getRootAsBase(bb);
|
||||
errors.maybeThrowError(baseRes);
|
||||
return baseRes;
|
||||
|
|
Loading…
Add table
Reference in a new issue