File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -524,6 +524,8 @@ export default class Helpers {
524
524
* @return {object } The possible operations to run with the datasource.
525
525
*/
526
526
bulk < TDocument = unknown > ( options : BulkHelperOptions < TDocument > , reqOptions : TransportRequestOptions = { } ) : BulkHelper < TDocument > {
527
+ assert ( ! ( reqOptions . asStream ?? false ) , 'bulk helper: the asStream request option is not supported' )
528
+
527
529
const client = this [ kClient ]
528
530
const { serializer } = client
529
531
if ( this [ kMetaHeader ] !== null ) {
Original file line number Diff line number Diff line change 17
17
* under the License.
18
18
*/
19
19
20
+ import { AssertionError } from 'assert'
20
21
import * as http from 'http'
21
22
import { createReadStream } from 'fs'
22
23
import { join } from 'path'
@@ -1161,6 +1162,36 @@ test('transport options', t => {
1161
1162
} )
1162
1163
} )
1163
1164
1165
+ t . test ( 'Should not allow asStream request option' , async t => {
1166
+ t . plan ( 2 )
1167
+
1168
+ const client = new Client ( {
1169
+ node : 'http://localhost:9200' ,
1170
+ } )
1171
+
1172
+ try {
1173
+ await client . helpers . bulk ( {
1174
+ datasource : dataset . slice ( ) ,
1175
+ flushBytes : 1 ,
1176
+ concurrency : 1 ,
1177
+ onDocument ( doc ) {
1178
+ return { index : { _index : 'test' } }
1179
+ } ,
1180
+ onDrop ( doc ) {
1181
+ t . fail ( 'This should never be called' )
1182
+ } ,
1183
+ } , {
1184
+ headers : {
1185
+ foo : 'bar'
1186
+ } ,
1187
+ asStream : true ,
1188
+ } )
1189
+ } catch ( err : any ) {
1190
+ t . ok ( err instanceof AssertionError )
1191
+ t . equal ( err . message , 'bulk helper: the asStream request option is not supported' )
1192
+ }
1193
+ } )
1194
+
1164
1195
t . end ( )
1165
1196
} )
1166
1197
You can’t perform that action at this time.
0 commit comments