Ciudatenie maxima cu PhantomJS

S-a lovit careva de cidatenii mari cu PhantomJS ? Uneori codul e evaluat alteori nu

Nu am avut probleme cu asta, sigur nu ai ceva problema de async care “schimba” ordinea de executie functie de ceva eveniment extern (api call etc…).

am avut cred si eu problema asta o data. Dupa strict mode nu se mai evalua nimic.

1 Like

Nu are treaba cu async

Vezi să nu ai vreo problema “timing sensitive”, de genul că scripul are nevoie de vreo resursă externă încărcată asincron, pe unele maşini încărcată în timp util, iar pe altele, prea târziu.

1 Like

Nu e race condition

1 Like

N-am folosit niciodata “use strict”, presupun că îţi “prinde” vreun “race condition”. Fară context nu cred ca avem cum să ne dăm seama ce anume, că înţeleg că sunt multe situaţii…

  • Disallows global variables. (Catches missing var declarations and typos in variable names)
  • Silent failing assignments will throw error in strict mode (assigning NaN = 5;)
  • Attempts to delete undeletable properties will throw (delete Object.prototype)
  • Requires all property names in an object literal to be unique (var x = {x1: “1”, x1: “2”})
  • Function parameter names must be unique (function sum (x, x) {…})
  • Forbids octal syntax (var x = 023; some devs assume wrongly that a preceding zero does nothing to change the number.)
  • Forbids the with keyword eval in strict mode does not introduce new variables
  • Forbids deleting plain names (delete x;)
  • Forbids binding or assignment of the names eval and arguments in any form
  • Strict mode does not alias properties of the arguments object with the formal parameters. (i.e. in function sum (a,b) return arguments[0] + b;} This works because arguments[0] is bound to a and so on. )
  • arguments.callee is not supported

Sursa: syntax - What does "use strict" do in JavaScript, and what is the reasoning behind it? - Stack Overflow

1 Like

Ce context ai nevoie sa intelegi? Codul de mai sus e exact ce e folosit. Am scos logica efectiva dupa use strict si am inlocuit-o cu un console.log, si nu merge. Pe alte masini merge.

Deci daca faci o pagina goala, care contine doar “use strict” si “console.log”, nu merge?

Nu stiu de unde vine problema nici acum

Pai adaugă cod până în punctul în care crapă, eu aşa aş face :slight_smile:

1 Like

Nu cred ca suntem “on the same page” dar e OK :slight_smile: Multumesc de ajutor.

Nu ai dat suficiente detalii despre problema. Poti sa descrii “ciudatenii”? Nu inteleg ce problema ai.
PhantomJS este deprecated [0], in schimb poti sa folosesti Chrome headless [1].

[0] https://groups.google.com/forum/#!topic/phantomjs/9aI5d-LDuNE
[1] https://developers.google.com/web/updates/2017/06/headless-karma-mocha-chai

2 Likes

Cred ca am dat suficiente detalii, daca ai intrebari concrete, poti sa intrebi, am raspuns la toate.
Stiu despre headless Chrome. Nu e o optiune pe termen scurt.