question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unclear docs re debug mode

See original GitHub issue

The docs currently show re debugging:

If you pass {debug: true} as one of the options in your initialize settings

It is unclear what is meant by initialize settings, and I couldn’t find reference to them nor their mention anywhere.

The changelog states that it can be passed to any Sync query, which is not clarifying, and the codebase mentions show only the Sync function takes the debug option

I would put a PR in if I had a clue how to enable debug

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fl0wcommented, Sep 10, 2019

Here’s another hack btw.

Bookshelf does a shallow copy of options on use (even down the eager chain). So if you pass an options object with a preset namespace (e.g. context, or scope) you can retain the full qb. This allows for some hacking.

class MyModel extends bookshelf.Model {
  initialize (...args) {
    super.initialize(...args)
    this.on('fetching', (modelCollection, attrs, options) => {
      if (!options.scope || !options.scope.qbs) return
      options.scope.qbs.push(options.query)
    })
  }
}

class MyCollection extends bookshelf.Collection {
  // same as above
}

bookshelf.Model = MyModel

class User extends bookshelf.Model {
  relation () {
    return this.belongsTo('Relation')
  }
  // ...
}

const fetchOptions = {
  withRelated: 'relation',
  scope: {
    qbs: []
  }
}

await bookshelf.model('User').forge().fetch(fetchOptions)

// pseudo but you get the idea
for (const qb of fetchOptions.scope.qbs)
  console.log(await bookshelf.knex.raw(`explain analyze ${qb.toString()}`)

// console.log's the result of an PG explain query for both User- and Relation queries

Edit; It’s late and this was of the top of my head but let me know if you want a more succinct example.

0reactions
davidfurlongcommented, Apr 23, 2018

I’m actually thinking of revamping the debug feature to be a little more custom. What kind of features are you missing with the current debug mode?

I don’t know. But debugging my latest issue (https://github.com/bookshelf/bookshelf/issues/1823) would have been easier if I could have seen a log of mutations or functions performed on models. Knex doesn’t show Bookshelf models ids, and logging yourself presumes you know what you’re looking for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation about --no-debug mode unclear (#153) · Issues
This may cause confusion when --no-debug mode is activated and all output goes to /dev/null without any mention in journal.
Read more >
Enabling debug logging - GitHub Docs
To enable runner diagnostic logging, set the following secret in the repository that contains the workflow: ACTIONS_RUNNER_DEBUG to true . To download runner ......
Read more >
Working in the Inspector - Unity - Manual
To turn on Debug mode, click the More Items (⋮) button to open the context menu, and select Debug. To return to Normal...
Read more >
What does Lightning Debug Mode do exactly?
The answer is: I misunderstood the docs plain and simply. Optimization and minification are performed on framework code only.
Read more >
Debugging methods and error types - HubSpot Developers
You can enable debug mode on a live page by loading the page with a ?hsDebug=true query string in the URL. Please note ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found