@devries-cameron20 / t3code-1 / commits / 34b12bea8e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(relay): finish unlinking when the DNS record is already gone (#38741)

Julius Marminge committed Nov 18, 2026 at 13:17 UTC 34b12bea8e7f0c1b721ad3be7c13a78b630030da
2 files changed +46 -38
infra/relay/src/environments/ManagedEndpointProvider.test.ts
+40 -37
@@ -1623,45 +1623,48 @@ describe("ManagedEndpointProvider", () => {
1623 }).pipe(Effect.provide(layer));
1624 });
1625
1626 - it.effect("treats already deleted remote resources as successfully deprovisioned", () => {
1627 - const allocationCalls: AllocationCall[] = [];
1628 - const notFound = { _tag: "NotFound" } as const;
1629 - const tunnelClient = ManagedEndpointProvider.ManagedEndpointTunnelClient.of({
1630 - ...makeTunnelClient(),
1631 - delete: () =>
1632 - Effect.fail(
1633 - new ManagedEndpointProvider.ManagedEndpointTunnelClientError({
1634 - operation: "delete",
1635 - tunnelId: "tunnel-id",
1636 - cause: notFound,
1637 - }),
1638 - ),
1639 - });
1640 - const dnsClient = ManagedEndpointProvider.ManagedEndpointDnsClient.of({
1641 - ...makeDnsClient(),
1642 - deleteRecord: () =>
1643 - Effect.fail(
1644 - new ManagedEndpointProvider.ManagedEndpointDnsClientError({
1645 - operation: "delete-record",
1646 - dnsRecordId: "created-record-id",
1647 - cause: notFound,
1648 - }),
1649 - ),
1650 - });
1651 - const layer = layerProvider(tunnelClient, dnsClient, makeAllocations(allocationCalls));
1652 -
1653 - return Effect.gen(function* () {
1654 - const provider = yield* ManagedEndpointProvider.ManagedEndpointProvider;
1655 - const key = { userId: "user_ABC", environmentId: "env_ABC" } as const;
1656 - yield* provider.provision({
1657 - ...key,
1658 - origin: { localHttpHost: "127.0.0.1", localHttpPort: 3773 },
1626 + it.effect.each(["NotFound", "RecordNotFound"])(
1627 + "treats deleted remote resources as deprovisioned (%s)",
1628 + (dnsErrorTag) => {
1629 + const allocationCalls: AllocationCall[] = [];
1630 + const notFound = { _tag: "NotFound" } as const;
1631 + const tunnelClient = ManagedEndpointProvider.ManagedEndpointTunnelClient.of({
1632 + ...makeTunnelClient(),
1633 + delete: () =>
1634 + Effect.fail(
1635 + new ManagedEndpointProvider.ManagedEndpointTunnelClientError({
1636 + operation: "delete",
1637 + tunnelId: "tunnel-id",
1638 + cause: notFound,
1639 + }),
1640 + ),
1641 });
1660 - yield* provider.deprovision(key);
1642 + const dnsClient = ManagedEndpointProvider.ManagedEndpointDnsClient.of({
1643 + ...makeDnsClient(),
1644 + deleteRecord: () =>
1645 + Effect.fail(
1646 + new ManagedEndpointProvider.ManagedEndpointDnsClientError({
1647 + operation: "delete-record",
1648 + dnsRecordId: "created-record-id",
1649 + cause: { _tag: dnsErrorTag },
1650 + }),
1651 + ),
1652 + });
1653 + const layer = layerProvider(tunnelClient, dnsClient, makeAllocations(allocationCalls));
1654
1662 - expect(allocationCalls.map((call) => call.operation)).toContain("removeClaimed");
1663 - }).pipe(Effect.provide(layer));
1664 - });
1655 + return Effect.gen(function* () {
1656 + const provider = yield* ManagedEndpointProvider.ManagedEndpointProvider;
1657 + const key = { userId: "user_ABC", environmentId: "env_ABC" } as const;
1658 + yield* provider.provision({
1659 + ...key,
1660 + origin: { localHttpHost: "127.0.0.1", localHttpPort: 3773 },
1661 + });
1662 + yield* provider.deprovision(key);
1663 +
1664 + expect(allocationCalls.map((call) => call.operation)).toContain("removeClaimed");
1665 + }).pipe(Effect.provide(layer));
1666 + },
1667 + );
1668
1669 it.effect("scopes managed endpoint resources by user", () => {
1670 const tunnelCalls: TunnelCall[] = [];
infra/relay/src/environments/ManagedEndpointProvider.ts
+6 -1
@@ -392,7 +392,12 @@ function isManagedEndpointNotFound(cause: unknown): boolean {
392 if (typeof cause !== "object" || cause === null) {
393 return false;
394 }
395 - if ("_tag" in cause && (cause._tag === "NotFound" || cause._tag === "TunnelNotFound")) {
395 + if (
396 + "_tag" in cause &&
397 + (cause._tag === "NotFound" ||
398 + cause._tag === "TunnelNotFound" ||
399 + cause._tag === "RecordNotFound")
400 + ) {
401 return true;
402 }
403 if ("status" in cause && cause.status === 404) {