Skip to content

Commit 9ab07d5

Browse files
elliotttJakeChampion
authored andcommitted
Update comment and move error logging to after promise rejection
1 parent dfd7fdd commit 9ab07d5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,14 +1374,8 @@ bool body_reader_then_handler(JSContext *cx, HandleObject body_owner, HandleValu
13741374
if (!JS_GetProperty(cx, chunk_obj, "value", &val))
13751375
return false;
13761376

1377+
// The read operation returned something that's not a Uint8Array
13771378
if (!val.isObject() || !JS_IsUint8Array(&val.toObject())) {
1378-
// TODO: check if this should create a rejected promise instead, so an
1379-
// in-content handler for unhandled rejections could deal with it. The read
1380-
// operation returned a chunk that's not a Uint8Array.
1381-
fprintf(stderr, "Error: read operation on body ReadableStream didn't respond with a "
1382-
"Uint8Array. Received value: ");
1383-
dump_value(cx, val, stderr);
1384-
13851379
// reject the request promise
13861380
if (Request::is_instance(body_owner)) {
13871381
RootedObject response_promise(cx, Request::response_promise(body_owner));
@@ -1397,6 +1391,10 @@ bool body_reader_then_handler(JSContext *cx, HandleObject body_owner, HandleValu
13971391
return JS::RejectPromise(cx, response_promise, exn);
13981392
}
13991393

1394+
// TODO: should we also create a rejected promise if a response reads something that's not a Uint8Array?
1395+
fprintf(stderr, "Error: read operation on body ReadableStream didn't respond with a "
1396+
"Uint8Array. Received value: ");
1397+
dump_value(cx, val, stderr);
14001398
return false;
14011399
}
14021400

0 commit comments

Comments
 (0)