Skip to content

hstry web sync --provider chatgpt returns empty — two bugs #2

Description

@svlytkin

Environment: macOS, hstry 0.5.18, Bun 1.3.13

Problem: hstry web sync --provider chatgpt completes silently but saves 0 conversations.

Two bugs found:

1. hstry web login chatgpt closes before auth completes

The login flow waits for textarea selector, but ChatGPT's landing page renders a textarea before the user authenticates (e.g. on the marketing/landing page). Playwright captures state immediately and closes — without the __Secure-next-auth.session-token cookie. Result: only Cloudflare cookies are saved.

Fix: wait for a selector that only appears post-auth, e.g.:

await page.waitForSelector('[data-testid="profile-button"], nav[aria-label="Chat history"]', { timeout: 0 });

2. request.newContext crashes on relative URL in Set-Cookie header

Without baseURL set, Playwright's internal _parseSetCookieHeader receives a relative URL (/backend-api/workspaces) from ChatGPT's API response and crashes:

TypeError: "/backend-api/workspaces" cannot be parsed as a URL.
at _parseSetCookieHeader (playwright-core/lib/coreBundle.js)

Fix: pass baseURL to request.newContext:

const api = await request.newContext({
  storageState: storageStatePath,
  baseURL: providerUrls[provider],  // add this
});

Both fixes are one-liners. Happy to open a PR if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions