Coder Social home page Coder Social logo

Comments (6)

pwnetrationguru avatar pwnetrationguru commented on September 16, 2024

We could also add a simple boolean argument to ScanJS.scan() that simply tells it whether or not we want to print to console. That might be hacky tho.

from scanjs.

mozfreddyb avatar mozfreddyb commented on September 16, 2024

We cannot use console.log inside a web worker, it causes console not defined errors.

Works for me in Firefox 29+, currently Aurora
I'll test what the spec says and come up with a solution. Happy to take this bug.

from scanjs.

pwnetrationguru avatar pwnetrationguru commented on September 16, 2024

Yah, I'm on FF 28.0 currently on this machine.

It does seem console.log with web workers has been a known issue for a while, but maybe browsers have updated since the articles I'm reading.

Just to be sure, you've cleared your cache?

from scanjs.

pwnetrationguru avatar pwnetrationguru commented on September 16, 2024

Anywho, I also don't mind turning off console.logs() for the client interface anyways and just use them in the server version, so maybe an additional parameter to scan() is the way to go but obviously whatever you think is best

from scanjs.

mozfreddyb avatar mozfreddyb commented on September 16, 2024

I don't think there's any benefit in disabling too many console.log calls. For end-users it's hidden away anyway, because you'd need to activate the devtools and then you're not just a user anymore ;)

I would suggest shimming console in the worker with something like this:

DEBUG=false;
if (typeof console === "undefined") {
  console = {};
  console.log = function consoleShim() {
    if (DEBUG === true) {
      postMessage(arguments.join(" "));
    }
  }
}

DEBUG is probably not the right name, as the worker will always print stuff, if console is available in the worker.

WDYT?

from scanjs.

pwnetrationguru avatar pwnetrationguru commented on September 16, 2024

That seems like a reasonable approach! I'd even be fine leaving out the DEBUG check and just printing, although I suppose there could be performance implications of that.

from scanjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.