Skip to content

Commit afcbc6f

Browse files
fix(relay): report unregistered Android watcher tokens
1 parent d1d09e6 commit afcbc6f

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎infra/relay/scripts/android-push-watch.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
} from "@t3tools/contracts";
1212
import type { RelayAgentActivityState } from "@t3tools/contracts/relay";
1313
import { projectThreadAwareness } from "@t3tools/shared/agentAwareness";
14+
import * as Cause from "effect/Cause";
15+
import * as Option from "effect/Option";
1416
import * as Clock from "effect/Clock";
1517
import * as Effect from "effect/Effect";
1618
import * as Layer from "effect/Layer";
@@ -59,6 +61,8 @@ class WatchStoppedError extends Schema.TaggedError<WatchStoppedError>()("WatchSt
5961
}
6062
}
6163

64+
const isWatchUnregisteredDeviceError = Schema.is(WatchUnregisteredDeviceError);
65+
6266
const preferences = {
6367
notificationsEnabled: true,
6468
liveActivitiesEnabled: true,
@@ -207,7 +211,14 @@ const main = Effect.gen(function* () {
207211
NodeRuntime.runMain(
208212
main.pipe(
209213
Effect.scoped,
210-
Effect.catchCause((cause) => Effect.fail(new WatchStoppedError({ cause }))),
214+
Effect.catchCause((cause) => {
215+
const failure = Cause.findErrorOption(cause);
216+
return Effect.fail(
217+
Option.isSome(failure) && isWatchUnregisteredDeviceError(failure.value)
218+
? failure.value
219+
: new WatchStoppedError({ cause }),
220+
);
221+
}),
211222
// Socket failures may contain credential-bearing request headers. Keep the
212223
// cause on the error, but print only the fixed message at the CLI boundary.
213224
Effect.tapError((error) => Effect.logError(error.message)),

0 commit comments

Comments
 (0)