From 86559eb7fccf521741c3ae25d2eb418933507011 Mon Sep 17 00:00:00 2001 From: chiyi Date: Thu, 16 Jul 2026 09:37:27 +0800 Subject: [PATCH] grok fix: statsig signer chunk locate regex include ~ (0~4v1h2zpw7n0.js); fixes locateSignerChunk not found -> conversations/new 403 anti-bot --- backend/internal/provider/grok/statsig_engine.go | 9 ++++++--- backend/internal/provider/grok/zz_probe_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/internal/provider/grok/statsig_engine.go b/backend/internal/provider/grok/statsig_engine.go index 59ffb07..eb00451 100644 --- a/backend/internal/provider/grok/statsig_engine.go +++ b/backend/internal/provider/grok/statsig_engine.go @@ -12,9 +12,9 @@ import ( "context" "crypto/sha256" "crypto/sha512" + _ "embed" "encoding/base64" "encoding/json" - _ "embed" "errors" "fmt" "io" @@ -44,8 +44,11 @@ const locateConcurrency = 24 var ( // chunkPathRe matches chunk URLs in the homepage; allChunkRefRe additionally // matches the loader-manifest's lazy refs (which drop the /_next/ prefix). - chunkPathRe = regexp.MustCompile(`/_next/static/chunks/[a-zA-Z0-9_.\-/]+\.js`) - allChunkRefRe = regexp.MustCompile(`(?:/_next/)?static/chunks/[a-zA-Z0-9_.\-/]+\.js`) + // The Turbopack content-hash alphabet includes '~' (e.g. 0~4v1h2zpw7n0.js) - + // the signer chunk is frequently one of these, so the class MUST list it or + // the signer is never fetched/located (403 anti-bot, static fallback goes stale). + chunkPathRe = regexp.MustCompile(`/_next/static/chunks/[a-zA-Z0-9_.~\-/]+\.js`) + allChunkRefRe = regexp.MustCompile(`(?:/_next/)?static/chunks/[a-zA-Z0-9_.~\-/]+\.js`) // goja's parser tries to fetch //# sourceMappingURL=... from disk and errors. sourceMapRe = regexp.MustCompile(`(?m)//[#@]\s*sourceMappingURL=\S*`) diff --git a/backend/internal/provider/grok/zz_probe_test.go b/backend/internal/provider/grok/zz_probe_test.go index 22a380d..98fef07 100644 --- a/backend/internal/provider/grok/zz_probe_test.go +++ b/backend/internal/provider/grok/zz_probe_test.go @@ -15,7 +15,7 @@ import ( http "github.com/bogdanfinn/fhttp" ) -var innerChunkRe = regexp.MustCompile(`static/chunks/[a-zA-Z0-9_.\-/]+\.js`) +var innerChunkRe = regexp.MustCompile(`static/chunks/[a-zA-Z0-9_.~\-/]+\.js`) func hnew(ctx context.Context, url, token string) (*http.Request, error) { req, err := http.NewRequest(http.MethodGet, url, nil)