iawia002/lux · error

douyin ttwid request failed

Error message

douyin ttwid request failed

What it means

To call douyin's web API, the extractor registers a ttwid cookie by POSTing a region payload to ttwid.bytedance.com/ttwid/union/register/. The HTTP call succeeded, but no ttwid=... value could be extracted from the Set-Cookie header, so cookie minting failed and extraction aborts. It is a header-content failure, not a transport error.

Source

Thrown at extractors/douyin/douyin.go:211

		"service":       "www.ixigua.com",
		"migrate_info":  map[string]string{"ticket": "", "source": "node"},
	}
	bytes, err := json.Marshal(body)
	if err != nil {
		return "", err
	}
	payload := strings.NewReader(string(bytes))
	resp, err := request.Request(http.MethodPost, "https://ttwid.bytedance.com/ttwid/union/register/", payload, nil)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close() // nolint
	cookie := resp.Header.Get("Set-Cookie")
	re := regexp.MustCompile(`ttwid=([^;]+)`)
	if match := re.FindStringSubmatch(cookie); match != nil {
		return match[1], nil
	}
	return "", errors.New("douyin ttwid request failed")
}

View on GitHub (pinned to dd00f6d258)

Solutions

  1. Retry — issuance is frequently transient.
  2. Log the response status and Set-Cookie header to confirm the endpoint itself answered rather than a proxy error page.
  3. Run from a residential IP or a different network.
  4. If the register contract changed, update the URL/payload in createCookie.

Example fix

// before
cookie, err := createCookie()
// after — retry the mint a few times before giving up
var cookie string
for i := 0; i < 3; i++ {
	cookie, err = createCookie()
	if err == nil {
		break
	}
	time.Sleep(time.Second * time.Duration(i+1))
}
Defensive patterns

Strategy: retry

Try / catch

Bounded retry: call createCookie up to 3 times with short backoff; between attempts log the HTTP status and Set-Cookie presence so a 4xx or a header-stripping proxy is visible. Abort the douyin batch only after all attempts fail.

Prevention

When it happens

Trigger: Bytedance returning an error body instead of issuing the cookie (payload/region mismatch); proxies or corporate MITM stripping Set-Cookie; a transient server-side change in cookie issuance.

Common situations: Running from cloud/datacenter IPs that bytedance flags; header-mangling middleboxes; temporary endpoint instability.

Related errors


AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15). Data as JSON: /api/errors/736b05a37237379f. Report an issue: GitHub.