mirror of
https://github.com/appy-one/acebase.git
synced 2026-05-25 06:02:14 -06:00
[GH-ISSUE #22] Realtime synchronization with a live data proxy not persisting to db #22
Labels
No labels
IndexedDB
browser
bug
dependencies
documentation
duplicate
enhancement
feature request
indexes
indexes
invalid
pull-request
query
question
transaction logging
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/acebase#22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @clibu on GitHub (Mar 17, 2021).
Original GitHub issue: https://github.com/appy-one/acebase/issues/22
Originally assigned to: @appy-one on GitHub.
I've written code based on https://github.com/appy-one/acebase#realtime-synchronization-with-a-live-data-proxy and have traced through the AceBase code in
data-proxy.tsand can see the underlying object get changed inset(target, prop, value, receiver)however nothing is written to the database and there are no errors.set()callscontext.flag('write', context.target.concat(prop));which callsscheduleSync()but db isn't updated.The specific property is a string assignment.
This is using IndexedDb in the Browser.
@clibu commented on GitHub (Mar 17, 2021):
A bit more info. Sometimes the data persists. I can't see a pattern. Maybe timing related. I've also see an empty IndexedDB record. ie.
valueis{}instead of{ someKey: "someValue" }@appy-one commented on GitHub (Mar 17, 2021):
Can you tell me a bit more about your setup? Are you using an AceBase instance with IndexedDB storage in combination with an AceBaseClient that syncs to a server, or just the IndexedDB as standalone db? Also, let me know which versions of the acebase packages you are using
@clibu commented on GitHub (Mar 17, 2021):
AceBase standalone with IndexedDB in the Browser. acebase": "^1.1.4
I'll update to the latest version.
@clibu commented on GitHub (Mar 17, 2021):
Updated to "acebase": "^1.2.3", - Same problems.
@clibu commented on GitHub (Mar 17, 2021):
I don't know if it is relevant but the path is just one node. ie "clibu_app" vs "clibu_app/blah"
@appy-one commented on GitHub (Mar 17, 2021):
Thanks, I'll try to reproduce
@appy-one commented on GitHub (Mar 17, 2021):
I've tested a couple of things but can't reproduce. What I should change to get it to fail?
@clibu commented on GitHub (Mar 17, 2021):
Same problem with your sample code.
TypeError: Cannot read property 'string' of nullin theassert()call. And nothing in the IndexedDB table.I'll dig deeper into the code and see what I can find.
FYI it is 6:50am now here in Australia. A new day starts.
@appy-one commented on GitHub (Mar 17, 2021):
Goodmorning early bird! 21:30 here in The Netherlands. 😊
Can you check the version of acebase-core in your node_modules. The latest version is 1.2.3.
You might want to
npm uninstall acebaseandnpm install acebaseto make sure the latest acebase-core is installed. I've fixed quite a few proxy issues, which is in the core package.@clibu commented on GitHub (Mar 17, 2021):
FWIW I'm using yarn. I did a
yarn remove acebaseyesterday andyarn add acebasepackage.json for acebase-core is "version": "1.2.3"
For you sample code when it fails I just see:
twice.
When it works ok I also see:
I'm starting to suspect some interference from other IndexedDB libs I'm using maybe causing this. More in next post.
@clibu commented on GitHub (Mar 17, 2021):
I'm using nanoSQL as the main db lib at present and Logux.io for Server Sync which also uses IndexedDB. I've been using both of these for quite some time without any issues. I'm looking at using AceBase to use as well as nanoSQL or possibly to replace it.
I've isolated nanoSQL and Logux so I only use AceBase proxy and am still seeing the same issue. I haven't noticed any issues using AceBase
db.ref( path ).update( doc )I'm not sure what to try next. I can tell you that if I step through a proxy update in the Chrome Debugger then it is more likely to work ok.
@clibu commented on GitHub (Mar 17, 2021):
Some more info. I'm toggling the value
displayNotesInGridbetween true and false of and seeing the following.The
target[prop] = value;at line 937 in data-proxy.ts is correct. However "/clibu_app/displayNotesInGrid" is not present in IndexedDB. Just key: "clibu_app", value: {}@appy-one commented on GitHub (Mar 17, 2021):
Have you tried removing/clearing the db for a fresh start? Do you get the same results?
@clibu commented on GitHub (Mar 17, 2021):
Yes many times. Helps for a bit then the issues reappear.
I've now just seen:
key: "", value: {clibu_app: {…}}which is really odd as clibu_app is never used as property value.
@appy-one commented on GitHub (Mar 17, 2021):
This is really hard without being able to reproduce. Are you using multiple proxies at the same time, other code that monitors values, or code that might change values in the db at the same time?
@appy-one commented on GitHub (Mar 17, 2021):
Can you set logLevel to 'verbose':
const db = AceBase.WithIndexedDB('debug', { logLevel: 'verbose' });, run the test code from above and copy/paste the console output?@clibu commented on GitHub (Mar 17, 2021):
There is another Proxy on the same DB but only the one with your sample code. I'll remove all of my AceBase code and just use your sample with verbose - after I've had some breakfast.😀
@appy-one commented on GitHub (Mar 17, 2021):
Enjoy your breakfast. I might be sleeping when you come back 😂
@clibu commented on GitHub (Mar 17, 2021):
Sleep well.😀 I'll keep trying to narrow this down.
I've removed all of my AceBase code and now just have you sample. I delete the db and refresh the Browser. Sometimes it works other times the assert raises an exception as per my earlier post.
This is the verbose output from a crash.
debug.acebase db:
key: "", value: {}I think I'll create a new app with just your code.
@clibu commented on GitHub (Mar 18, 2021):
Ok I created the attached Node app and am seeing the same issue.
AceBase V1.2.3 Node v15.11.0 Windows 10 Home Version 10.0.19042 Build 19042 Dell XPS 15
I delete the
debug.acebasefolder and> node proxy1.jsand get the same error every time. If I don't delete the folder and run it a second time it works as expected.I also ran just your sample code in the Browser and as before - worked sometimes.
I hope you can reproduce it with the attached files.
proxy1.zip
@clibu commented on GitHub (Mar 18, 2021):
More info. I've rebooted my XPS15 and same problem. I also tried it on another Win10 Desktop PC - same problem. I updated Node on it to the latest release 15.12.0
@appy-one commented on GitHub (Mar 18, 2021):
Thanks! 👍🏼 I'll dive into it after I've taken the kids to school
@appy-one commented on GitHub (Mar 18, 2021):
Looks like I found the issue 🥳
@clibu commented on GitHub (Mar 18, 2021):
👍 I hope you were able to reproduce it.
@appy-one commented on GitHub (Mar 18, 2021):
Yes! I've made a couple of changes, will publish after some more testing
@appy-one commented on GitHub (Mar 18, 2021):
I published my changes in acebase-core v1.2.4, let me know if this fixes it!
@clibu commented on GitHub (Mar 18, 2021):
Look forward to trying it.
Were you able to reproduce the issue?
On Thu, 18 Mar 2021, 21:10 Ewout Stortenbeker, @.***>
wrote:
@appy-one commented on GitHub (Mar 18, 2021):
I was able to reproduce the failing assert upon creation of the record, not on updates thereafter. BUT, there were a couple things that could have caused those to fail:
ref.context({ acebase_proxy: {...} })) used to update the database was not set for setting the default value, causing the proxy to think the value was updated from an external source, overwriting the in-memory cache value.DataReferenceused by the proxy was the same instance as the one used to create the proxy, causing the context set by the proxy to also be used by other code performing update operations on that sameDataReference- causing the proxy to think the update was done by itself, not updating its cached value.cacheobject reference was updated inside the proxy code, but the external code using the proxy was still poking in the old referencedcacheobject.@clibu commented on GitHub (Mar 18, 2021):
Ok, looking much, much better. I am seeing one weird thing, but it might be my code. I'll look into it in the morning,
Thanks for looking at this so quickly.
@clibu commented on GitHub (Mar 18, 2021):
This seems a little odd, I just want to check with you.
I've got a path named: "'clibu_app'" which is Proxied. When I start the app, and "'clibu_app'" has no IndexedDB record and I don't assign any key/value to it I'm seeing
key: "", value: "{clibu_app: { clibu_app } }". Expanding this in Chrome DevTools shows "No properties".As soon as I assign a value everything looks as I would expect.
key: "". value: {}and a new recordkey: "clibu_app", value: {someObject}Other than that all seem ok so far. But I haven't had breakfast yet.😉
@appy-one commented on GitHub (Mar 18, 2021):
Yes, that is by design. I would guess you create the proxy using default value
{}like sodb.ref('clibu_app').proxy({})? This will create the path "clibu_app" with value{}if it doesn't exist. Because it's an empty object (has no children), it is stored in the parent record. Once you assign properties to the "clibu_app" node, it will be stored in its own dedicated record.@clibu commented on GitHub (Mar 18, 2021):
Thanks and understood. It just looked a little odd. Hopefully full steam ahead now. I have other questions and suggestions, but will leave those until I get further into using AceBase.
@appy-one commented on GitHub (Mar 18, 2021):
You're welcome, Closing this one!