Warn about trying to output DOM nodes / complex objects

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
43/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, jquery, typescript
Ambito
backend, web-dev

Direzione di ricerca

The issue provides a minimal pageFunction repro returning a jQuery object as body, plus a sample run showing dataset submission failures. Start by locating where page function results are serialized and sent to the dataset; reproduce with the provided function. Done when returning a DOM node or complex object produces a clear warning instead of hanging or failing the dataset request.

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

Descrizione

enhancement

Happens more often with web-scraper, some people try to return a jQuery instance (like $('selector') instead of $('selector').text()) or a DOM node on the return object, and it either fails with Error: Evaluation failed: RangeError: Maximum call stack size exceeded, get stuck forever (up until the handle page timeout) or the dataset endpoint fails with the humongous JSON generated with a lot of circular references.

sample run https://my.apify.com/view/runs/ysnZZXg9qxp2Plp24

{"level":"WARNING","msg":"Retry failed 4 times and will be repeated in 14623ms","originalError":"API request failed on retry number 5","errorDetails":{"url":"http://xxxx/v2/datasets/xxxx/items","method":"POST","qs":{"token":"*********"},"hasBody":true,"statusCode":502,"iteration":5}}

minimal repro code:

async function pageFunction(context) {
    // This statement works as a breakpoint when you're trying to debug your code. Works only with Run mode: DEVELOPMENT!
    // debugger; 

    const $ = context.jQuery;

    return {
        url: context.request.url,
        body: $('body')
    };
}
Lingua principale
TypeScript
Stelle
149
Fork
59
Merge medio
12h 38m
PR unite (30g)
2

Preparare l'ambiente

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.

Altre issue di apify/actor-scraper

Tutte le issue di apify/actor-scraper

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.