The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as HttpClient from "effect/http/HttpClient"; |
| 6 | import { MinimumLogLevel } from "effect/References"; |
| 7 | import * as pathe from "pathe"; |
| 8 | |
| 9 | const { test } = Test.make({ |
| 10 | providers: Cloudflare.providers(), |
| 11 | dev: true, |
| 12 | }); |
| 13 | |
| 14 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 15 | |
| 16 | // Regression test for the secondary symptom of #1109: when no consumer is |
| 17 | // registered for a queue, the dev registry's `ExternalQueueConsumer` accepts |
| 18 | // and drops the message with a warning — but it must still settle the |
| 19 | // producer's `send()` promise. It previously responded without draining the |
| 20 | // request body, which left `send()` pending forever (workerd's queue client |
| 21 | // only settles once the body is consumed). |
| 22 | test.provider( |
| 23 | "plain worker send() to unconsumed queue resolves", |
| 24 | (stack) => |
| 25 | Effect.gen(function* () { |
| 26 | yield* stack.destroy(); |
| 27 | const deployed = yield* stack.deploy( |
| 28 | Effect.gen(function* () { |
| 29 | const queue = yield* Cloudflare.Queues.Queue("DropProbeQueue"); |
| 30 | const worker = yield* Cloudflare.Worker("drop-probe-worker", { |
| 31 | main: pathe.resolve(import.meta.dirname, "fixtures/queue-local-worker.ts"), |
| 32 | env: { QUEUE: queue }, |
| 33 | }); |
| 34 | return { queue, worker }; |
| 35 | }), |
| 36 | ); |
| 37 | const client = yield* HttpClient.HttpClient; |
| 38 | const res = yield* client |
| 39 | .get(`${deployed.worker.url}/send?text=drop-me`) |
| 40 | .pipe(Effect.timeout("20 seconds"), Effect.orDie); |
| 41 | expect(res.status).toBe(200); |
| 42 | yield* stack.destroy(); |
| 43 | }).pipe(logLevel), |
| 44 | { |
| 45 | tags: [ |
| 46 | "provider:cloudflare", |
| 47 | "provider:cloudflare:queue", |
| 48 | "provider:cloudflare:worker", |
| 49 | "local", |
| 50 | ], |
| 51 | timeout: 120_000, |
| 52 | }, |
| 53 | ); |