fix(extension): match redirect extra info to its response status
why
NavigationResponseTracker keeps the latest responseReceivedExtraInfo per request id. A redirect hop shares its request id with the final response, so when the final response has no extra info of its own (for example, it is served from the disk cache), the 3xx hop's headers, such as its set-cookie and location, are applied to the final 200 response returned by goto().
what changed
selectResponseapplies stored extra info only when itsstatusCodematches the response status, and always clears the stored entry.- New
tests/navigation-response-tracker.test.tswith a fake page and session. - Changeset: patch for the extension, the TS SDK and the Python SDK.
test plan
- New test: 302 extra info, then a 200 document response from the disk cache with the same request id. On main,
headerValue("set-cookie")returns the redirect'shop=1; with this change it is null. A second test checks that matching early extra info is still applied. pnpm --filter @browserbasehq/stagehand-extension test:unit: 78 files, 1266 passed.pnpm exec turbo run fmt:check lint typecheck --continue: 47/47 tasks passed.
Written with help from an AI coding agent; I've reproduced and tested it as described.
🤖 Generated with Claude Code
Summary by cubic
Fixes goto() sometimes returning a navigation response with headers from a redirect hop instead of the final response. Redirect hops share the request ID with the final response, so when the final response has no extra info of its own (for example, it comes from the disk cache), the 3xx hop's headers, such as its set-cookie and location, were applied to it.
- Stored extra info is now applied only when its
statusCodematches the response status, and the stored entry is always cleared afterward. - Adds unit tests covering both a matching early extra info and a redirect followed by a disk-cache response.