Intermittent AppView.detectChangesInternal error


#1

I am getting this weird error I cannot track down.
I have a server-side only Method which I call.
In my debugger the server-side call never gives an error and performs as expected:
Here is the server code:

     if (!myItem.long_url) {
            // nothing to shorten, just save
            myItem.short_link = ""; // clear if needed
            if (myItem._id) {
                LibraryItems.update(myItem._id, {$set:myItem}, (err, cnt)=> {
                    if (err){
                        console.log("0 err: " + err);
                        throw new Meteor.Error('Error', err);
                    }
                });
            } else {
                LibraryItems.insert(<LibraryItem>myItem);
            }
            return "success";
        }

The culprite is the ‚Äúupdate‚ÄĚ. The update is successful on the database‚Ķbut i get the exception below and my app locks up. And it is intermintent?
The client side call…always returns success.
Client code:

            this.call('save.library.item', this.selectedItem, (err, res)=> {
                console.log("err: " + err);
                console.log("res: " + res);
                if (res == "success"){
                    //success
                    this.generateTags();
                    console.log("3");
                    this.childModal.hide();
                    console.log("Succesfully saved...");
                } else {
                    console.log("Failed save..." + err);
                }
            }, true);

I have no idea.

Exception in queued task: TypeError: Cannot read property 'type' of undefined
    at _View_Library2.detectChangesInternal (Library.template.js:1752:42)
    at _View_Library2.AppView.detectChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12713:14)
    at _View_Library0.AppView.detectContentChildrenChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12731:19)
    at _View_Library0.detectChangesInternal (Library.template.js:1046:8)
    at _View_Library0.AppView.detectChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12713:14)
    at _View_Library_Host0.AppView.detectViewChildrenChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12739:19)
    at _View_Library_Host0.detectChangesInternal (Library.template.js:36:8)
    at _View_Library_Host0.AppView.detectChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12713:14)
    at _View_Saturn0.AppView.detectContentChildrenChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12731:19)
    at _View_Saturn0.AppView.detectChangesInternal (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12723:14)

app.js:1553 err: undefined
app.js:1554 res: success
app.js:1558 3
app.js:1560 Succesfully saved…

browser_adapter.js:93 EXCEPTION: SyntaxError: Unexpected token u in JSON at position 0
browser_adapter.js:84 EXCEPTION: SyntaxError: Unexpected token u in JSON at position 0BrowserDomAdapter.logError @ browser_adapter.js:84BrowserDomAdapter.logGroup @ browser_adapter.js:94ExceptionHandler.call @ exception_handler.js:65(anonymous function) @ application_ref.js:337schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:310Zone.runGuarded @ zone.js:218NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:339Zone.runTask @ zone.js:237ZoneTask.invoke @ zone.js:405
browser_adapter.js:84 STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:67(anonymous function) @ application_ref.js:337schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:310Zone.runGuarded @ zone.js:218NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:339Zone.runTask @ zone.js:237ZoneTask.invoke @ zone.js:405
browser_adapter.js:84 SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at Library.editTweet (library.component.ts:149)
at _View_Library2._handle_click_24_0 (Library.template.js:1798)
at dom_renderer.js:254
at dom_events.js:27
at ZoneDelegate.invoke (zone.js:306)
at Object.onInvoke (ng_zone_impl.js:53)
at ZoneDelegate.invoke (zone.js:305)
at Zone.runGuarded (zone.js:215)
at NgZoneImpl.runInnerGuarded (ng_zone_impl.js:86)BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:68(anonymous function) @ application_ref.js:337schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:310Zone.runGuarded @ zone.js:218NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:339Zone.runTask @ zone.js:237ZoneTask.invoke @ zone.js:405
zone.js:241 Uncaught SyntaxError: Unexpected token u in JSON at position 0(…)Library.editTweet @ library.component.ts:149_View_Library2._handle_click_24_0 @ Library.template.js:1798(anonymous function) @ dom_renderer.js:254(anonymous function) @ dom_events.js:27ZoneDelegate.invoke @ zone.js:306onInvoke @ ng_zone_impl.js:53ZoneDelegate.invoke @ zone.js:305Zone.runGuarded @ zone.js:215NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:86NgZone.runGuarded @ ng_zone.js:240outsideHandler @ dom_events.js:27ZoneDelegate.invokeTask @ zone.js:339Zone.runTask @ zone.js:237ZoneTask.invoke @ zone.js:405


#2

Two things here:

  1. Your syntax for $set is wrong (this is the important one).
  2. On the server you don’t need use the callback form of the update (this just makes the code cleaner).
try {
  const cnt = LibraryItems.update(myItem._id, {$set:{ myItem: someNewValue } });
  // do something with cnt here
} catch (err) {
  throw new Meteor.Error('Error', err);
}

#3

The myItem in $set:myItem is a JSON object…works fine in dozens of places.

I added the callbacks to do error catching and try/catch also … no errors are ever thrown.

I moved the Method out of the /sever directory into a both location…errors stopped completely.

I had moved it to the /server because I added a rawCollection() call to the method and they do not work on the client side… so I rewrote the method without it.

My hypothesize is the client was trying to do a display update based on the database changes…causing the error.

As I said I move the method to a /both directory…problem solved.


#4

AUGH!!! Premature…errors are back.

No idea‚Ķ they stopped on dozens of tests. I did a build and deploy‚ÄĒ on the deployed version again.

And after restarting my dev IDE…they are back in that box also.

Exception in queued task: TypeError: Cannot read property ‚Äėtype‚Äô of undefined
at _View_Library2.detectChangesInternal (Library.template.js:1752:42)
at _View_Library2.AppView.detectChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12713:14)
at _View_Library0.AppView.detectContentChildrenChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12731:19)
at _View_Library0.detectChangesInternal (Library.template.js:1046:8)
at _View_Library0.AppView.detectChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12713:14)
at _View_Library_Host0.AppView.detectViewChildrenChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12739:19)
at _View_Library_Host0.detectChangesInternal (Library.template.js:36:8)
at _View_Library_Host0.AppView.detectChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12713:14)
at _View_Saturn0.AppView.detectContentChildrenChanges (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12731:19)
at _View_Saturn0.AppView.detectChangesInternal (http://localhost:3000/packages/modules.js?hash=055cd96324e091a102dbaabeb4a6fc6a3ec0d7bf:12723:14)


#5

Yes, that should be fine as you’re not changing the _id, I just hadn’t noticed that from the code you posted :slight_smile:

Have you tried just doing the update with the short_link (or are there other changes not captured here)?

LibraryItems.update(myItem._id, {$set: { short_link: '' } } );

#6

Thanks for the help…

  1. The database always updated correctly and the _id did not change.
  2. No errors were ever thrown.
  3. This IS the problem.
  4. I changed the $set to all possible fields that could be changed (8)…seems to work now.

I guess Meteor is sending an error message to the client when I did an update like $set:myItem.
No idea why it works, but still gives the error…impossible to process every case I guess?

Thanks again!!
Very helpful.