Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error running example. TypeError: content.getContent is not a function #1

Open
cdetrio opened this issue Jun 28, 2017 · 1 comment
Open

Comments

@cdetrio
Copy link

cdetrio commented Jun 28, 2017

When I try to run the example:

$ bin/js-fuzz ../fuzz.js

TypeError: content.getContent is not a function
    at Log.List.add.List.addItem.List.appendItem (/Users/macbook/dev_fuzz/js-fuzz/node_modules/blessed/lib/widgets/list.js:297:61)
    at Log.List.setItems (/Users/macbook/dev_fuzz/js-fuzz/node_modules/blessed/lib/widgets/list.js:384:12)
    at Log.log (/Users/macbook/dev_fuzz/js-fuzz/node_modules/blessed-contrib/lib/widget/log.js:26:8)
    at Stats.<anonymous> (/Users/macbook/dev_fuzz/js-fuzz/lib/src/Stats.js:203:66)
    at emitOne (events.js:96:13)
    at Stats.emit (events.js:191:7)
    at Stats.log (/Users/macbook/dev_fuzz/js-fuzz/lib/src/Stats.js:76:14)
    at Cluster.<anonymous> (/Users/macbook/dev_fuzz/js-fuzz/lib/src/Cluster.js:149:67)
    at emitOne (events.js:96:13)
    at Cluster.emit (events.js:191:7)

It appears related to this line and the blessed dependency.

@adrianheine
Copy link

I assume this is about a parser error in the example. Try the following instead:

const JSON5 = require('json5')

exports.fuzz = input => {
  input = input.toString('utf8') // we give you buffers by default

  let isPlainJSON = true
  let isJSON5 = true
  try { JSON.parse(input) } catch (e) { isPlainJSON = false }
  try { JSON5.parse(input) } catch (e) { isJSON5 = false }

  // We catch and thrown errors and mark them as failures
  if (isPlainJSON && !isJSON5) {
    throw new Error('Found a string that was JSON but not JSON5');
  }

  return isPlainJSON ? 1 : 0
}

adrianheine added a commit to adrianheine/js-fuzz that referenced this issue Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants