0
0
Fork 0
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:
Ryan Dahl 2019-06-08 18:11:47 -04:00 committed by GitHub
parent d60bdb6350
commit 8ec5276d30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;