mirror of
https://github.com/appy-one/acebase.git
synced 2026-05-25 06:02:14 -06:00
[GH-ISSUE #61] Library is crashing while firing it's change event on query #45
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#45
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 @directtosumit on GitHub (Jan 25, 2022).
Original GitHub issue: https://github.com/appy-one/acebase/issues/61
Originally assigned to: @appy-one on GitHub.
I had set sort, filter and change listener at the node "/bpm";
function gotMatches(snaps) {
const data={};
snaps.forEach(snap => {
data[snap.key] = snap.val();
});
lis(data);
}
const valueChanged=() => {
db.get({include, exclude}).then(gotMatches).catch(err);
};
function matchAdded() {
valueChanged();
}
function matchChanged() {
valueChanged();
}
function matchRemoved() {
valueChanged();
}
db
.on('add', matchAdded)
.on('change', matchChanged)
.on('remove', matchRemoved);
valueChanged();
[database] Reading node "/bpm/kytk61qh001doazk0c46fvkr" from address 0,10
0|index | [database] Node "/bpm/kytk61qh001doazk0c46fvkr" being updated: adding 0 keys (), updating 1 keys ("value"), removing 0 keys ()
0|index | [database] Node "/bpm/kytk61qh001doazk0c46fvkr" saved at address 0,10 - 1 addresses, 50 bytes written in 1 chunk(s)
0|index | TypeError: Cannot convert undefined or null to object
0|index | at Function.keys ()
0|index | at Object.childChangedCallback [as callback] (/Local Tcp Server/node_modules/acebase/src/api-local.js:728:60)
0|index | at /Local Tcp Server/node_modules/acebase/src/storage.js:494:25
0|index | at Array.forEach ()
0|index | at Object.trigger (/Local Tcp Server/node_modules/acebase/src/storage.js:493:18)
0|index | at /Local Tcp Server/node_modules/acebase/src/storage.js:1066:51
0|index | at Array.forEach ()
0|index | at triggerAllEvents (/Local Tcp Server/node_modules/acebase/src/storage.js:1012:14)
0|index | at processTicksAndRejections (node:internal/process/task_queues:78:11)
PM2 | App [index:0] exited with code [1] via signal [SIGINT]
@appy-one commented on GitHub (Jan 25, 2022):
Thanks for reporting, I'll take a look
@appy-one commented on GitHub (Jan 26, 2022):
I managed to reproduce the error, looks like a bit of refactoring on my end is needed to fix it.
A very quick fix for you would be to edit line 866 in api-local.js, change
'notify_child_changed'to'child_changed'. Make the same edit in line 715.Let me know if that works for now.
@appy-one commented on GitHub (Jan 26, 2022):
By the way, I see that you are manually refreshing the data in your code upon changes, but that is not necessary. The essence of a realtime query is that your query results are updated in realtime, so you don't have to execute the query again after changes. See the following example:
The
add,changeandremovecallbacks update the local state without executing the query again@directtosumit commented on GitHub (Jan 27, 2022):
I did this way, because I had applied sort() based on the time in
descending order on the database reference, which is lost if I do it in the
way you suggested.
At this moment I have edited my code to update at,
"bpm", with data {:{...oldData, ...newData}}
previously I was updating at,
"bpm/", with data {...newData}
now I am getting no benifit of update(), since it is working same as the
set(), I hope the problem will be fixed on the next update of the library,
I will update it then.
On Wed, Jan 26, 2022, 9:30 PM Ewout Stortenbeker @.***>
wrote:
@appy-one commented on GitHub (Feb 1, 2022):
It's a little unclear to me why you would do your updates on a different target? The node you are updating has no effect on events firing, and has no effect on a realtime query either?
@appy-one commented on GitHub (Feb 21, 2022):
I just published acebase version 1.15.0, let me know if it works