Skip to content

fix: handle XHR responseType='json' when accessing response data#121

Merged
lcomplete merged 1 commit intolcomplete:devfrom
wdonsong:patch-2
Mar 14, 2026
Merged

fix: handle XHR responseType='json' when accessing response data#121
lcomplete merged 1 commit intolcomplete:devfrom
wdonsong:patch-2

Conversation

@wdonsong
Copy link
Copy Markdown
Contributor

Summary

Fix XHR response interceptor to handle responseType='json' correctly on Android browsers.

Problem

The extension fails to capture Twitter/X.com content on Android browsers (e.g., Lemur Browser).

Root cause: When XMLHttpRequest.responseType is set to 'json', accessing the
responseText property throws a DOMException:

DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest':
The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json').

This is per MDN
specification
:

If responseType is set to anything other than the empty string or "text", accessing responseText
will throw InvalidStateError exception.

Reproduction Steps

  1. Install Huntly extension on Lemur Browser (Android)
  2. Visit x.com and browse tweets
  3. Check browser console - see the DOMException error
  4. Tweets are not captured to database

Solution

Handle responseType='json' case by using the response property instead of responseText:

// Before
responseHandler(this.responseText, this.responseURL);

// After
let responseText;
if (this.responseType === 'json') {
  responseText = typeof this.response === 'string'
    ? this.response
    : JSON.stringify(this.response);
} else {
  responseText = this.responseText;
}
responseHandler(responseText, this.responseURL);

Testing

- Tested on Lemur Browser (Android) - Twitter content now captured successfully
- Tested on Chrome Desktop - no regression, existing functionality works

Files Changed

- app/extension/src/request_interceptor.ts

---

@lcomplete lcomplete merged commit b6fdc84 into lcomplete:dev Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants