Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: do not mutate original opts
  • Loading branch information
metcoder95 committed May 29, 2024
commit 82d7fb30e47e6c4b25eaaeec833299060a047de2
3 changes: 1 addition & 2 deletions lib/handler/retry-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class RetryHandler {

this.dispatch = handlers.dispatch
this.handler = handlers.handler
this.opts = dispatchOpts
this.opts = { ...dispatchOpts, body: wrapRequestBody(opts.body) }
this.abort = null
this.aborted = false
this.retryOpts = {
Expand Down Expand Up @@ -68,7 +68,6 @@ class RetryHandler {
this.end = null
this.etag = null
this.resume = null
this.opts.body = wrapRequestBody(this.opts.body)

// Handle possible onConnect duplication
this.handler.onConnect(reason => {
Expand Down
8 changes: 2 additions & 6 deletions test/retry-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ test('Should account for network and response errors', async t => {
await t.completed
})

test('Issue #3288', async t => {
test('Issue #3288 - request with body (asynciterable)', async t => {
t = tspl(t, { plan: 6 })
const server = createServer()
const dispatchOptions = {
Expand Down Expand Up @@ -244,7 +244,6 @@ test('Issue #3288', async t => {
return true
},
onData (chunk) {
console.log('chunk', chunk)
return true
},
onComplete () {
Expand Down Expand Up @@ -755,7 +754,6 @@ test('retrying a request with a body', async t => {
t = tspl(t, { plan: 1 })

server.on('request', (req, res) => {
console.log({ counter })
switch (counter) {
case 0:
req.destroy()
Expand Down Expand Up @@ -835,7 +833,6 @@ test('retrying a request with a body (stream)', async t => {
t = tspl(t, { plan: 3 })

server.on('request', (req, res) => {
console.log({ counter })
switch (counter) {
case 0:
res.writeHead(500)
Expand Down Expand Up @@ -988,8 +985,7 @@ test('should not error if request is not meant to be retried', async t => {
t.strictEqual(Buffer.concat(chunks).toString('utf-8'), 'Bad request')
},
onError (err) {
console.log({ err })
t.fail()
t.fail(err)
}
}
})
Expand Down