HTTP Server Requests Timeout After 2 Seconds When Downloading Files

I have written an http server using effect's httpserver module, but I am running into a weird issue where my requests timeout after exactly 2 seconds. Specifically, I get the following message in my logs.
timestamp=2024-06-06T16:54:50.965Z level=INFO fiber=#22 cause="All fibers interrupted without errors." http.span.1=2030ms http.status=499 http.method=POST http.url=/


I download a file when a post request is made with the following code (based on a thread on this discord):
export const downloadFile = (url: string, outputDirectory: string) =>
  Effect.gen(function* (_) {
    const filename = new URL(url).pathname.slice(1);
    const fs = yield* FileSystem.FileSystem;
    const path = yield* Path.Path;
    const filePath = path.join(outputDirectory, `${filename}.mp3`);
    yield* fs.makeDirectory(outputDirectory, { recursive: true });
    yield* Effect.log(`downloading file to ${filePath}`);

    const response = yield* Http.request.get(url).pipe(Http.client.fetchOk);

    yield* Effect.log(`response.statusCode: ${response.status}`);

    yield* response.stream.pipe(Stream.run(fs.sink(filePath)));

    yield* Effect.log("done streaming to file");

    return yield* Effect.succeed(filePath);
  });
.
The code does log response.statusCode 200 before dying.

My code is based on https://github.com/Effect-TS/effect/blob/b64b6ed15289ea617fb9df21a5f7301a07d4e7c0/packages/platform-node/examples/http-router.ts.

Does anyone have any ideas as what could be causing this?
Was this page helpful?