Skip to content

Commit e1211a5

Browse files
authored
fix(request): reject NaN highWaterMark during option validation (#5062)
1 parent c8d50b4 commit e1211a5

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/api/api-request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RequestHandler extends AsyncResource {
2121
throw new InvalidArgumentError('invalid callback')
2222
}
2323

24-
if (highWaterMark && (typeof highWaterMark !== 'number' || highWaterMark < 0)) {
24+
if (highWaterMark != null && (!Number.isFinite(highWaterMark) || highWaterMark < 0)) {
2525
throw new InvalidArgumentError('invalid highWaterMark')
2626
}
2727

test/node-test/client-errors.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ test('retry idempotent inflight', async (t) => {
11611161
})
11621162

11631163
test('invalid opts', async (t) => {
1164-
const p = tspl(t, { plan: 5 })
1164+
const p = tspl(t, { plan: 7 })
11651165

11661166
const client = new Client('http://localhost:5000')
11671167
client.request(null, (err) => {
@@ -1186,6 +1186,14 @@ test('invalid opts', async (t) => {
11861186
p.ok(err instanceof errors.InvalidArgumentError)
11871187
p.strictEqual(err.message, 'invalid highWaterMark')
11881188
})
1189+
client.request({
1190+
path: '/',
1191+
method: 'GET',
1192+
highWaterMark: Number.NaN
1193+
}, (err) => {
1194+
p.ok(err instanceof errors.InvalidArgumentError)
1195+
p.strictEqual(err.message, 'invalid highWaterMark')
1196+
})
11891197

11901198
await p.completed
11911199
})

0 commit comments

Comments
 (0)