Setting Timeout on HTTP Requests with Node and Undici
Hello, I would like to set a timeout on HTTP requests sent with Platform/Node. I'm trying to replace the default NodeHttpClient with the Undici implementation in the following test code:
I think I should use NodeHttpClient.makeUndici but I don't really get the interaction with the Dispatcher.
it('should trigger an error if the timeout is exceeded', async () => {
const response = await pipe(
HttpClientResponse.void(
pipe(
HttpClientRequest.get(${HTTP_BIN_URL}/delay/1),
HttpClient.fetch,
),
),
Effect.catchTag('RequestError', () => Effect.fail('timeout')),
Effect.provideServiceEffect(
HttpClient.HttpClient,
pipe(
NodeHttpClient.make,
NodeHttpClient.withUndiciOptions({
signal: AbortSignal.timeout(500),
}),
Effect.provide(NodeHttpClient.agentLayer),
),
),
Effect.runPromiseExit,
);
expect(response).toStrictEqual(Exit.fail('timeout'));
});I think I should use NodeHttpClient.makeUndici but I don't really get the interaction with the Dispatcher.
