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

fatal crash related to gun.off() #48

Open
leonardpauli opened this issue Feb 28, 2018 · 8 comments
Open

fatal crash related to gun.off() #48

leonardpauli opened this issue Feb 28, 2018 · 8 comments

Comments

@leonardpauli
Copy link

Not exactly sure what I did, but probably one of:

gun.get('testing').put({pointers: null})
gun.get(id).put(null)
gun.get(id).off()
gun.get(id).get(id2).off()
gun.get(id).map(v=> v.off())
gun.get(id).map().val(v=> v.off())
gun.get(id).map().val((v, k)=> gun.get(id).get(k).off())
const item = gun.get(id); item.map().val((v, k)=> item.get(k).off())

gun.get('name').put({key: 'value'});
gun.get('name').val(console.log)
gun.get('name').off()
gun.get('name').val(console.log)

...when trying to figure out how to remove data.

node_modules/levelup/lib/levelup.js:145
    throw new ReadError('get() requires a key argument')
    ^
ReadError: get() requires a key argument
    at LevelUP.get (/node_modules/levelup/lib/levelup.js:145:11)
    at Adapter.read (/node_modules/gun-level/dist/Adapter/index.js:114:20)
    at Object.next (/node_modules/gun-level/dist/index.js:32:14)
    at Object.onto [as on] (/node_modules/gun/gun.js:203:19)
    at Function.Gun.on.get (/node_modules/gun/gun.js:793:35)
    at Object.root [as next] (/node_modules/gun/gun.js:697:14)
    at Object.next (/node_modules/gun/nts.js:17:20)
    at Object.next (/node_modules/gun/lib/bye.js:11:45)
    at Object.onto [as on] (/node_modules/gun/gun.js:203:19)
    at receive (/node_modules/gun/lib/ws.js:84:7)
error Command failed with exit code 1.

I suspect context.get['#'] ("key") becomes null/undefined somehow which breaks it all, even after restart. Adding if (!key) return _this.afterRead(context, null) // possibly warn? or is this correct? at line 112 in /dist/Adapter/index.js should do.

...or just make it use the radix storage thing? :)

leonardpauli added a commit to leonardpauli/gun-level that referenced this issue Mar 3, 2018
@leonardpauli
Copy link
Author

Added it in https://github.com/LeonardPauli/gun-level/tree/48-no-key-crash (npm install gun-level-lptmp)

@amark
Copy link
Collaborator

amark commented Mar 5, 2018

@leonardpauli if you submit a pull request with this we'll accept it and get it merged :D

@509dave16
Copy link
Contributor

509dave16 commented Jul 8, 2018

@amark I ran into this same error.

TL;DR

Think it hasn't something to do with Gun user not existing on server node. Just a hunch

Environment: Chrome Latest, Node 8.11.2, Mac OS X

Repos

Reproduction

Here's the rough step of steps to reproduce error:

  1. Start dev server for client app(i.e. should default to port 8080)
  2. Start the gun server on port 8081
  3. When I attempt to do gun.user().auth(<username>,<password>, cb) the expected ack is returned. But this caused the gun.off error on the server. Might have something to do with the user not existing yet.

Screenshots/Gif

And here's some screenshots and a gif.

client-app-error

gun-server-error

gif-of-error-occurring

Code Snippets

@amark
Copy link
Collaborator

amark commented Jul 8, 2018

@509dave16 your project looks really cool, I'd love to hear more? Thanks for a detailed report, it is exceptional!!

This issue is specific to gun-level or GUN in general? Because gun.user is from SEA in the main repo, not gun-level.

If this is specific to gun-level, I can't guarantee gun-level staying up to date with main GUN (the localStorage version is officially maintained). We have a new thing called RAD for GUN that is intended to replace most storage systems (and will probably have its own indexedDB plugin that will have more official support, but that is a ways out), however it isn't quite stable/ready yet.

So I don't want to slow down progress on your app just because of gun-level. Are you able to avoid it for now?

@509dave16
Copy link
Contributor

509dave16 commented Jul 8, 2018

@amark Really appreciate the reply. And that is good point you made regarding the scope. Should try to do some unauthenticated ops separately and compare results. I’ll probably stick with localStorage or IndexedDB adapters for the moment moving forward.

I have been looking at syncing solutions because my consulting company is trying to get a custom Google Forms like product released that has syncing incorporated. So that we have some passive income. Currently the app has a php api with manual polling and the different client implementations have been using local storage. Which we have found is quite slow. Data would be sectioned off by companies. And then people given links to different forms would fill them out as an application(instance of the form data). The forms could be filled out offline and then be pushed to the server/peers when online. Likewise if there were any additions to the forms that needed to be filled out, those would be pushed up to device when back online.

I investigated Realm.js but it is limited to React Native at the moment. Though it did have access control levels. I have investigated using PouchDB with Couch base or CouchDB as well. Doing little demos with them. Even wrote a relational orm around relational-pouch: https://github.com/509dave16/ranksdb. But then found about RxDB which does that better. Problem with those is the locked down single js function solution to write access. And read access is only scoped at a database level. Can’t go as fine grained as documents. And deployment is somewhat hairy. And I was using superlogin to handle one database per user which is no longer maintained.

So then I found Gun.js, OrbitDB, and SyncedDB. I went with Gun.js because it’s smallest, actively maintained, most storage adapters, and it’s ACL/node level permissions are promising. I plan to write a NanoSQL adapter for gun. Then on the server or client where intensive reporting like logic needs to be done, complex queries could be performed.

The sample app you see above is just an app for cycling through randomized selections of whatever you might want to randomize. Like those extreme sports you talked about in a talk you have ;) .Here’s a demo hosted site: https://random-that.firebaseapp.com/lists
This uses just in memory seed data. And I was just working on converting it to use Gun.js for persistence and auth. Only really concerned with this on a per user basis. No sharing. The randomizing app is just for testing the waters for the most part.

But I did run into problems where clearing cookies in the browser. Removed any users
created by Gun.user().create(...). Was hoping that created users would be replicated to nodes. Like one on a server.

I can create a separate issue for that.

@509dave16
Copy link
Contributor

509dave16 commented Jul 8, 2018

There are a bunch of sync and performance concerns with our current api for the forms product. Hoping Gun could be an alternative for us. We’ll also be doing for client work a contact management app as well as a similar forms app for a heater company as a PWA.

@509dave16
Copy link
Contributor

@amark Switching to another adapter completely avoided the issue I was encountering. Thanks for your input today.

@amark
Copy link
Collaborator

amark commented Jul 9, 2018

@509dave16 sounds awesome. Great work. Thanks for the deeper understanding/explanation!

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

3 participants