Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 25, 2024
1 parent a3094ac commit 78dc2e6
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/docs/api/RedirectHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Returns: `RedirectHandler`

### Parameters

- **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandlers) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every redirection.
- **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandler) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every redirection.
- **maxRedirections** `number` (required) - Maximum number of redirections allowed.
- **opts** `object` (required) - Options for handling redirection.
- **handler** `object` (required) - Handlers for different stages of the request lifecycle.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/api/RetryHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ It represents the retry state for a given request.

### Parameter `RetryHandlers`

- **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandlers) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every retry.
- **handler** Extends [`Dispatch.DispatchHandlers`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler) (required) - Handler function to be called after the request is successful or the retries are exhausted.
- **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandler) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every retry.
- **handler** Extends [`Dispatch.DispatchHandler`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler) (required) - Handler function to be called after the request is successful or the retries are exhausted.

>__Note__: The `RetryHandler` does not retry over stateful bodies (e.g. streams, AsyncIterable) as those, once consumed, are left in a state that cannot be reutilized. For these situations the `RetryHandler` will identify
>the body as stateful and will not retry the request rejecting with the error `UND_ERR_REQ_RETRY`.
Expand Down
2 changes: 1 addition & 1 deletion lib/interceptor/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ module.exports = (opts = {}) => {
opts.body.on('error', () => {}).destroy()
}

respondWithCachedValue(result, age)
respondWithCachedValue(result, age, null)
}

if (typeof result.then === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion test/types/client.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ expectAssignable<Client>(new Client('', {
expectAssignable<Dispatcher['dispatch']>(dispatcher)
return (opts, handlers) => {
expectAssignable<Dispatcher.DispatchOptions>(opts)
expectAssignable<Dispatcher.DispatchHandlers>(handlers)
expectAssignable<Dispatcher.DispatchHandler>(handlers)
return dispatcher(opts, handlers)
}
}]
Expand Down
6 changes: 3 additions & 3 deletions test/types/dispatcher.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ expectAssignable<Dispatcher.ComposedDispatcher>(new Dispatcher().compose(
expectAssignable<Dispatcher['dispatch']>(dispatcher)
return (opts, handlers) => {
expectAssignable<Dispatcher.DispatchOptions>(opts)
expectAssignable<Dispatcher.DispatchHandlers>(handlers)
expectAssignable<Dispatcher.DispatchHandler>(handlers)
return dispatcher(opts, handlers)
}
}
Expand All @@ -188,15 +188,15 @@ expectAssignable<Dispatcher.ComposedDispatcher>(new Dispatcher().compose([
expectAssignable<Dispatcher['dispatch']>(dispatcher)
return (opts, handlers) => {
expectAssignable<Dispatcher.DispatchOptions>(opts)
expectAssignable<Dispatcher.DispatchHandlers>(handlers)
expectAssignable<Dispatcher.DispatchHandler>(handlers)
return dispatcher(opts, handlers)
}
},
(dispatcher) => {
expectAssignable<Dispatcher['dispatch']>(dispatcher)
return (opts, handlers) => {
expectAssignable<Dispatcher.DispatchOptions>(opts)
expectAssignable<Dispatcher.DispatchHandlers>(handlers)
expectAssignable<Dispatcher.DispatchHandler>(handlers)
return dispatcher(opts, handlers)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ expectAssignable<Dispatcher.DispatcherComposeInterceptor>(Undici.interceptors.re
expectAssignable<Dispatcher.DispatcherComposeInterceptor>(Undici.interceptors.cache())

const client = new Undici.Client('', {})
const handler: Dispatcher.DispatchHandlers = {}
const handler: Dispatcher.DispatchHandler = {}

const redirectHandler = new Undici.RedirectHandler(client, 10, {
path: '/', method: 'GET'
Expand Down
2 changes: 1 addition & 1 deletion types/agent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare class Agent extends Dispatcher {
/** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
destroyed: boolean
/** Dispatches a request. */
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
}

declare namespace Agent {
Expand Down
2 changes: 1 addition & 1 deletion types/dispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ declare namespace Dispatcher {
export interface DispatchHandler {
onRequestStart?(controller: DispatchController, context: any): void;
onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
onResponseStart?(controller: DispatchController, statusCode: number, statusMessage?: string, headers: IncomingHttpHeaders): void;
onResponseStart?(controller: DispatchController, statusCode: number, statusMessage: string | null, headers: IncomingHttpHeaders): void;
onResponseData?(controller: DispatchController, chunk: Buffer): void;
onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
onResponseError?(controller: DispatchController, error: Error): void;
Expand Down
2 changes: 1 addition & 1 deletion types/env-http-proxy-agent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default EnvHttpProxyAgent
declare class EnvHttpProxyAgent extends Dispatcher {
constructor (opts?: EnvHttpProxyAgent.Options)

dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
}

declare namespace EnvHttpProxyAgent {
Expand Down
8 changes: 4 additions & 4 deletions types/handlers.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Dispatcher from './dispatcher'

export declare class RedirectHandler implements Dispatcher.DispatchHandlers {
export declare class RedirectHandler implements Dispatcher.DispatchHandler {
constructor (
dispatch: Dispatcher,
maxRedirections: number,
opts: Dispatcher.DispatchOptions,
handler: Dispatcher.DispatchHandlers,
handler: Dispatcher.DispatchHandler,
redirectionLimitReached: boolean
)
}

export declare class DecoratorHandler implements Dispatcher.DispatchHandlers {
constructor (handler: Dispatcher.DispatchHandlers)
export declare class DecoratorHandler implements Dispatcher.DispatchHandler {
constructor (handler: Dispatcher.DispatchHandler)
}
2 changes: 1 addition & 1 deletion types/mock-agent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare class MockAgent<TMockAgentOptions extends MockAgent.Options = MockAgent.
get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable
get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable
/** Dispatches a mocked request. */
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
/** Closes the mock agent and waits for registered mock pools and clients to also close before resolving. */
close (): Promise<void>
/** Disables mocking in MockAgent. */
Expand Down
2 changes: 1 addition & 1 deletion types/mock-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare class MockClient extends Client implements Interceptable {
/** Intercepts any matching requests that use the same origin as this mock client. */
intercept (options: MockInterceptor.Options): MockInterceptor
/** Dispatches a mocked request. */
dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean
dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
/** Closes the mock client and gracefully waits for enqueued requests to complete. */
close (): Promise<void>
}
Expand Down
2 changes: 1 addition & 1 deletion types/mock-pool.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare class MockPool extends Pool implements Interceptable {
/** Intercepts any matching requests that use the same origin as this mock pool. */
intercept (options: MockInterceptor.Options): MockInterceptor
/** Dispatches a mocked request. */
dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean
dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
/** Closes the mock pool and gracefully waits for enqueued requests to complete. */
close (): Promise<void>
}
Expand Down
2 changes: 1 addition & 1 deletion types/proxy-agent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ProxyAgent
declare class ProxyAgent extends Dispatcher {
constructor (options: ProxyAgent.Options | string)

dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
close (): Promise<void>
}

Expand Down
4 changes: 2 additions & 2 deletions types/retry-handler.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Dispatcher from './dispatcher'

export default RetryHandler

declare class RetryHandler implements Dispatcher.DispatchHandlers {
declare class RetryHandler implements Dispatcher.DispatchHandler {
constructor (
options: Dispatcher.DispatchOptions & {
retryOptions?: RetryHandler.RetryOptions;
Expand Down Expand Up @@ -111,6 +111,6 @@ declare namespace RetryHandler {

export interface RetryHandlers {
dispatch: Dispatcher['dispatch'];
handler: Dispatcher.DispatchHandlers;
handler: Dispatcher.DispatchHandler;
}
}

0 comments on commit 78dc2e6

Please sign in to comment.