prerender: read non-HTML main documents through response.stream()

Aperta
#311 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend, web-dev

Direzione di ricerca

Start by reading src/index.js:58-108, src/index.js:157, src/index.js:172, and src/index.js:259, then check the linked Puppeteer and browserless issues for the required stream measurement. The proposal depends on HTTPResponse.stream() returning the full PDF viewer response; acceptance also calls for local server tests covering extensionless PDF and docx, HTML, size limits, rejection fallback, and one download. Done means the measurement supports the approach and every acceptance check passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

claude --dangerously-skip-permissions --resume f585c3fe-624a-4f4c-9b28-edf7962e7046

Blocked on: puppeteer HTTPResponse.stream() (https://github.com/puppeteer/puppeteer/issues/7863) and https://github.com/microlinkhq/browserless/issues/1022.

Problem

defaultGetMode (src/index.js:259) picks fetch for PDF/media/office only from the URL (isMediaUrl, isPdfUrl, isOfficeUrl). A URL without an extension that serves application/pdf or an office document goes to prerender, where page.content() (src/index.js:172) returns the viewer shell instead of the document.

Prerender also always starts a full parallel got download as a fallback (src/index.js:157). For non-HTML responses that second download is the only way to get the bytes, and it is a plain HTTP client, so it fails where the browser session passed an antibot challenge.

Proposal

Behind an opt-in flag (the existing default stays unchanged):

  1. In the prerender evaluate, listen to the main-frame document response.
  2. If its content-type is not HTML, call response.stream() right away and collect the body (capped at PDF_SIZE_TRESHOLD / the existing size limits).
  3. Route the bytes into the existing fetch-mode pipeline (extractSafe for PDF, mutool, pandoc for office, toEncode, src/index.js:58-108) and cancel the parallel fetch.
  4. HTML responses keep the current page.content() path untouched.

Acceptance

  • Only start once the browserless measurement shows stream() returns the full body for the PDF-viewer case. If it does not, close this issue with the measurement.
  • Tests against a local server: extensionless PDF, extensionless docx, HTML baseline (unchanged output), body over the size cap, stream() rejection (falls back to the current behavior).
  • Prove a single download: server hit count is 1 for the extensionless PDF with the flag on.
Lingua principale
JavaScript
Stelle
102
Fork
10
Merge medio
2h 51m
PR unite (30g)
7

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.