Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inconsistent invocation of callbacks for bad values #123

@PsychoLlama

Description

@PsychoLlama

When passing in bad values to .set or .put, sometimes the callbacks are invoked, and sometimes they aren't. For example:

Gun().get('test').set(NaN, function () {
  console.log(arguments)
})
// the function is never called

But if you pass in Infinity instead, the callback will fire, passing in an error object with the message "Invalid value at [soul]!". But it doesn't stop there! There's even inconsistency between .set and .put (even though .set uses .put under the hood).

Gun().get('test').path('callback madness').set(Infinity, callback)
// invoked, error given. Let's try put this time...
Gun().get('test').path('callback madness').put(Infinity, callback)
// not invoked, no error! What?

These errors might be the last string of sanity that beginners have, since gun doesn't throw traditional errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions