aboutsummaryrefslogtreecommitdiff
path: root/castle-search/src/errors.ts
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-11-06 03:33:30 +0000
committerIgor Soarez <igor@soarez.org>2026-11-06 03:33:30 +0000
commit561f0ee076c684a79fd5671af1bad0894f33e4de (patch)
tree7849677412a8b5f80835fa812f2e255f222a2c82 /castle-search/src/errors.ts
parent147b3b1507ebcdf5912fbd4c474c9dfb35265148 (diff)
castle-search: resolve Google links lazily, in Chrome, not eagerly over plain HTTPHEADmaster
The Node-side resolver sent one curl-like request per result with no cookies, JS or browser; Google answers that with its 'Verifying your request' countdown after a handful, and the testing itself triggered it. A click or direct navigation in Chrome redirects at once (measured). Search now leaves Google links wrapped and prints the breadcrumb Google shows for each. castle_cdp_resolve follows one wrapped link in a Chrome tab when the agent picks it, accepts only google.com/goto?url=<token>, and reports the verification page instead of waiting it out.
Diffstat (limited to 'castle-search/src/errors.ts')
-rw-r--r--castle-search/src/errors.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/castle-search/src/errors.ts b/castle-search/src/errors.ts
index 2318b27..95fa7ef 100644
--- a/castle-search/src/errors.ts
+++ b/castle-search/src/errors.ts
@@ -81,3 +81,22 @@ export class SearchAbortedError extends Error {
}
export const messageOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
+
+/**
+ * Google answered a `/goto` link with its "Verifying your request" page instead
+ * of redirecting. It is a bot check with a countdown; it is reported, never
+ * waited out or clicked through.
+ */
+export class GoogleVerificationError extends Error {
+ override readonly name = "GoogleVerificationError";
+ readonly pageUrl: string;
+ constructor(pageUrl: string) {
+ super(
+ "Google showed its \"Verifying your request\" page instead of redirecting, so the real URL could not be " +
+ "read. This is a rate-based bot check: opening many links in a row triggers it, and it eases after a few " +
+ "minutes. Do not retry in a loop. Use the breadcrumb printed under the result to judge where it points, " +
+ "pick fewer links, or search again with another engine (duckduckgo, brave, bing), which return real URLs.",
+ );
+ this.pageUrl = pageUrl;
+ }
+}