File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -527,6 +527,8 @@ export default class Helpers {
527
527
* @return {object } The possible operations to run with the datasource.
528
528
*/
529
529
bulk < TDocument = unknown > ( options : BulkHelperOptions < TDocument > , reqOptions : TransportRequestOptions = { } ) : BulkHelper < TDocument > {
530
+ assert ( ! ( reqOptions . asStream ?? false ) , 'bulk helper: the asStream request option is not supported' )
531
+
530
532
const client = this [ kClient ]
531
533
const { serializer } = client
532
534
if ( this [ kMetaHeader ] !== null ) {
Original file line number Diff line number Diff line change 18
18
*/
19
19
20
20
import FakeTimers from '@sinonjs/fake-timers'
21
+ import { AssertionError } from 'assert'
21
22
import { createReadStream } from 'fs'
22
23
import * as http from 'http'
23
24
import { join } from 'path'
@@ -1336,6 +1337,37 @@ test('transport options', t => {
1336
1337
} )
1337
1338
} )
1338
1339
1340
+ t . test ( 'Should not allow asStream request option' , async t => {
1341
+ t . plan ( 2 )
1342
+
1343
+ const client = new Client ( {
1344
+ node : 'http://localhost:9200' ,
1345
+ } )
1346
+
1347
+ try {
1348
+ await client . helpers . bulk ( {
1349
+ datasource : dataset . slice ( ) ,
1350
+ flushBytes : 1 ,
1351
+ concurrency : 1 ,
1352
+ onDocument ( doc ) {
1353
+ return { index : { _index : 'test' } }
1354
+ } ,
1355
+ onDrop ( doc ) {
1356
+ t . fail ( 'This should never be called' )
1357
+ } ,
1358
+ refreshOnCompletion : true
1359
+ } , {
1360
+ headers : {
1361
+ foo : 'bar'
1362
+ } ,
1363
+ asStream : true ,
1364
+ } )
1365
+ } catch ( err : any ) {
1366
+ t . ok ( err instanceof AssertionError )
1367
+ t . equal ( err . message , 'bulk helper: the asStream request option is not supported' )
1368
+ }
1369
+ } )
1370
+
1339
1371
t . end ( )
1340
1372
} )
1341
1373
You can’t perform that action at this time.
0 commit comments