HeadlessX icon indicating copy to clipboard operation
HeadlessX copied to clipboard

[Bug]: Frontend response is different from backend

Open eusoutes opened this issue 9 months ago • 1 comments

Preliminary Checks

  • [x] I have searched existing issues for similar problems
  • [x] I have read the troubleshooting documentation
  • [x] I am using a supported version of HeadlessX

HeadlessX Version

v2.0.2

Installation Method

npm install

Affected App/Package

apps/web (Frontend Dashboard)

Environment

Ubuntu 22.04

Bug Description

I'm trying to scrape a shopee page, however, when I make a request via api, both simple request and sse return a non-coherent html to which there are no original elements of the page. But when I do it via the interface, the html is assembled normally, with all the elements and when I download the html via the interface, using the "Save" option the html appears complete, like the original from shopee.

Via api: request > scraping > non-coherent html (without elements)

Via interface request > scraping > coherent html (with all real elements)

Expected Behavior

that the API response was equal to that of the interface

Actual Behavior

the API response was not the same as the interface response

Steps to Reproduce

  1. Make this request: {"url":"https://shopee.com.br/search?keyword=mini-tripé-flexível-com-suporte-para-celular","type":"html-js","profileId":"606f29d7-51e6-4fa4-85a2-8556a5b68f77","stealth":true,"options":{"waitForSelector":"li.shopee-search-item-result__item","timeout":30000}}

Error Logs

there are no errors in the log

Configuration

NODE_ENV=development
PORT=8000

Severity

Low (minor issue, workaround available)

Browser Context

Not browser related

Additional Context

No response

Contribution

  • [ ] I am willing to help fix this bug
  • [x] I can provide additional testing
  • [x] I can help with documentation updates

eusoutes avatar Feb 27 '26 01:02 eusoutes

Issue #32 is fixed and pushed to develop.

  • Branch: develop
  • Commit: 0abfb20
  • Message: fix(api): align REST and SSE HTML rendering for dynamic pages
  • Push: origin/develop

What changed:

  • REST scraping now honors timeout and options.timeout, matching the dashboard/streaming path.
  • REST and SSE both wait for DOM stability before extracting JS-rendered HTML, instead of capturing too early after selector detection.
  • Screenshot capture also uses the same post-selector stabilization step.

Files:

  • ScrapeControllerV2.ts
  • ScraperService.ts
  • StreamingScraperService.ts
  • pageStability.ts

Validation:

  • pnpm --filter headlessx-api build passed
  • Verified both sync and streaming scraping on a JS-rendered page return full rendered HTML instead of partial/incoherent markup

saifyxpro avatar Mar 06 '26 21:03 saifyxpro