Skip to content

Commit 8ec5276

Browse files
authored
Add asserts checking that async ops return null (#2463)
1 parent d60bdb6 commit 8ec5276

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

js/dispatch.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function sendAsync(
9191
data,
9292
false
9393
);
94-
util.assert(response == null);
94+
util.assert(response == null); // null indicates async.
9595
const promise = util.createResolvable<msg.Base>();
9696
promiseTable.set(cmdId, promise);
9797
return promise;
@@ -106,10 +106,11 @@ export function sendSync(
106106
): null | msg.Base {
107107
const [cmdId, response] = sendInternal(builder, innerType, inner, data, true);
108108
util.assert(cmdId >= 0);
109-
if (response == null || response.length === 0) {
109+
util.assert(response != null); // null indicates async.
110+
if (response!.length === 0) {
110111
return null;
111112
} else {
112-
const bb = new flatbuffers.ByteBuffer(response);
113+
const bb = new flatbuffers.ByteBuffer(response!);
113114
const baseRes = msg.Base.getRootAsBase(bb);
114115
errors.maybeThrowError(baseRes);
115116
return baseRes;

0 commit comments

Comments
 (0)