forked from nodejs/undici
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mert Can Altin
committed
Jun 19, 2024
1 parent
6782734
commit eb29a2a
Showing
3 changed files
with
24 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
'use strict' | ||
|
||
const RetryHandler = require('../handler/retry-handler') | ||
const createResponseErrorInterceptor = require('./response-error') | ||
|
||
module.exports = globalOpts => { | ||
return dispatch => { | ||
const responseErrorInterceptor = createResponseErrorInterceptor(dispatch) | ||
|
||
return function retryInterceptor (opts, handler) { | ||
const wrappedHandler = { | ||
onConnect: handler.onConnect ? handler.onConnect.bind(handler) : undefined, | ||
onHeaders: handler.onHeaders.bind(handler), | ||
onData: handler.onData.bind(handler), | ||
onComplete: handler.onComplete.bind(handler), | ||
onError: handler.onError.bind(handler) | ||
} | ||
|
||
const finalHandler = new RetryHandler( | ||
{ ...opts, retryOptions: { ...globalOpts, ...opts.retryOptions } }, | ||
{ handler: wrappedHandler, dispatch } | ||
return dispatch( | ||
opts, | ||
new RetryHandler( | ||
{ ...opts, retryOptions: { ...globalOpts, ...opts.retryOptions } }, | ||
{ | ||
handler, | ||
dispatch | ||
} | ||
) | ||
) | ||
|
||
return responseErrorInterceptor(opts, finalHandler) | ||
} | ||
} | ||
} |