@@ -1239,43 +1239,42 @@ function serializeTypedArray(
1239
1239
}
1240
1240
1241
1241
function serializeBlob ( request : Request , blob : Blob ) : string {
1242
- const id = request . nextChunkId ++ ;
1243
- request . pendingChunks ++ ;
1242
+ const model : Array < string | Uint8Array > = [ blob . type ] ;
1243
+ const newTask = createTask (
1244
+ request ,
1245
+ model ,
1246
+ null ,
1247
+ false ,
1248
+ request . abortableTasks ,
1249
+ ) ;
1244
1250
1245
1251
const reader = blob . stream ( ) . getReader ( ) ;
1246
1252
1247
- const model : Array < string | Uint8Array > = [ blob . type ] ;
1248
-
1249
1253
function progress (
1250
1254
entry : { done : false , value : Uint8Array } | { done : true , value : void } ,
1251
1255
) : Promise < void > | void {
1252
1256
if ( entry . done ) {
1253
- const blobId = outlineModel ( request , model ) ;
1254
- const blobReference = '$B' + blobId . toString ( 16 ) ;
1255
- const processedChunk = encodeReferenceChunk ( request , id , blobReference ) ;
1256
- request . completedRegularChunks . push ( processedChunk ) ;
1257
- if ( request . destination !== null ) {
1258
- flushCompletedChunks ( request , request . destination ) ;
1259
- }
1257
+ pingTask ( request , newTask ) ;
1260
1258
return ;
1261
1259
}
1262
- // TODO: Emit the chunk early and refer to it later.
1260
+ // TODO: Emit the chunk early and refer to it later by dedupe .
1263
1261
model . push ( entry . value ) ;
1264
1262
// $FlowFixMe[incompatible-call]
1265
1263
return reader . read ( ) . then ( progress ) . catch ( error ) ;
1266
1264
}
1267
1265
1268
1266
function error ( reason : mixed ) {
1269
1267
const digest = logRecoverableError ( request , reason ) ;
1270
- emitErrorChunk ( request , id , digest , reason ) ;
1268
+ emitErrorChunk ( request , newTask . id , digest , reason ) ;
1269
+ request . abortableTasks . delete ( newTask ) ;
1271
1270
if ( request . destination !== null ) {
1272
1271
flushCompletedChunks ( request , request . destination ) ;
1273
1272
}
1274
1273
}
1275
1274
// $FlowFixMe[incompatible-call]
1276
1275
reader . read ( ) . then ( progress ) . catch ( error ) ;
1277
1276
1278
- return '$' + id . toString ( 16 ) ;
1277
+ return '$B ' + newTask . id . toString ( 16 ) ;
1279
1278
}
1280
1279
1281
1280
function escapeStringValue ( value : string ) : string {
0 commit comments