1

I think I found a bug...

Just updated to the new Breeze.JS v1.5 and now I'm getting the following error:

Error: Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.
   at dependentObservable (http://localhost:54663/Scripts/knockout-3.2.0.debug.js:1712:17)
   at setDpValueSimple (http://localhost:54663/Scripts/breeze.debug.js:5083:5)
   at defaultPropertyInterceptor (http://localhost:54663/Scripts/breeze.debug.js:4945:13)
   at write (http://localhost:54663/Scripts/breeze.debug.js:16415:25)
   at dependentObservable (http://localhost:54663/Scripts/knockout-3.2.0.debug.js:1710:17)
   at proto.setProperty (http://localhost:54663/Scripts/breeze.debug.js:16454:13)
   at Anonymous function (http://localhost:54663/Scripts/breeze.debug.js:7918:21)
   at proto._updateTargetFromRaw (http://localhost:54663/Scripts/breeze.debug.js:7891:9)
   at updateEntity (http://localhost:54663/Scripts/breeze.debug.js:14782:9)
   at mergeEntity (http://localhost:54663/Scripts/breeze.debug.js:14755:13)

Any ideas the best way to fix this real quick?

UPDATE: Here's my proposed fix at line 5083 in breeze.debug.js from this:

rawAccessorFn(newValue);

to this:

if (ko.isWriteableObservable(rawAccessorFn))
    rawAccessorFn(newValue);

Not sure of any underlying issues with this fix but it works for me :)

UPDATE 2: The Fix is NOW at line 5167 in breeze.debug.js v1.5.1

UPDATE 3: The Fix is NOW at line 5191 in breeze.debug.js v1.5.2

Can we get this FIX implemented in the source?

2 Answers2

1

We haven't changed the breeze knockout adapter is quite awhile. What version were you running previously?

Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • I believe we were running the latest 1.4.x – user2839646 Oct 16 '14 at 17:40
  • Please show us the property definition. Is it a client property you added to the entity? Is it a read-only property from the server? I ask because we're trying to understand how it became a KO computed property and why breeze is in charge of writing to it. – Ward Oct 21 '14 at 17:51
  • @Ward We just updated to the new 1.5.1 and had go in and add the FIX stated above (now on line 5167). To answer your question about how it gets in there, we are extending the entity added computed fields using the metadataStore.registerEntityTypeCtor() – user2839646 Dec 03 '14 at 19:57
1

So tho is an unmapped property, yes? And its value is determined how? By computation from other properties and data, yes?

So who is trying to set the value? You or Breeze? If Breeze, under what circumstances?

I ask all of these questions because it is not obvious to me that silently ignoring an attempt to set a RO property is better than throwing. Seems to me that Ko is telling you something important.

I would make such a change if breeze were setting the property in some internal phase that you can't touch (e.g. during query result processing or entity import).

A small repro on jsfiddle or plunker would really help.

Thanks.

Ward
  • 17,793
  • 4
  • 37
  • 53
  • Yes and Yes. This is a computed extension of the entity that uses properties on the entity to determine its value. I am not trying to write to my computed, it is breeze trying to write to my computed (when initializing an entity) as outlined in my original post. It appears that breeze doesn't take into account the possibility of extending the entity with computed observables on the client side. Once I added this "fix" all is well again :) – user2839646 Dec 18 '14 at 19:07