Strange behaviour of firebase transaction -


my firebase looks this:

enter image description here

this test code (coffee script):

firebase = require 'firebase'  ref = new firebase 'https://my_firebase.firebaseio.com/items'  ref.once 'child_added', (snapshot) ->   childref = snapshot.ref()   console.log "child_added", childref.tostring(), snapshot.val()   childref.transaction(     (data) ->       console.log 'transaction on data', data       return if !data or data.my_key isnt 'my_val'       data.my_key = 'new_val'       return data     ,     (err, commited, snapshot) ->       if err         console.error 'error', err         return       console.log 'commited? '+commited       console.log 'server data', snapshot.val()     ,     false   ) 

and output:

child_added https://my_firebase.firebaseio.com/items/item1 { my_key: 'my_val' } transaction on data null commited? false server data null 

same happens when third parameter of transaction(...) true. make code work, have change ref.once 'child_added', (snapshot) -> ref.on 'child_added', (snapshot) -> (once on). after change output is:

child_added https://my_firebase.firebaseio.com/items/item1 { my_key: 'my_val' } transaction on data { my_key: 'my_val' } commited? true server data { my_key: 'new_val' } 

it seems reason when using once data not synced , local snapshot not updated , transaction "thinks" there no data under ref. bug or doing wrong? know transactions updatefunction can called more 1 time, , third parameter (i have tried true , false options it) still can't understand why transaction not work when using once obtain child.

the transaction should succeed, , run on correct state of data, run in "uncached" state, meaning run against client's local copy of data (likely null), try commit change server (which fail), , re-try transaction.

this normal, , expected. if, however, transaction not ever succeed, recommend reaching out support folks @ support@firebase.com continue troubleshooting problem.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -