Gregivy / simpleddp

An easy to use DDP client library
MIT License
165 stars 19 forks source link

uncaught error when "nosub" message is received #25

Closed hems closed 4 years ago

hems commented 4 years ago

Today I noticed this error when trying to run a page which needs user login and for some weird reason it's getting the nosub message.

this is yielding the following error: image

When investigating further ( i added a breakpoint on google chrome ) turns out that the "m" argument don't have an ".error" property when getting the "nosub" message: image

I believe the error comes from "await ...ready()":

https://github.com/Gregivy/simpleddp/blob/master/src/classes/ddpSubscription.js#L114

I'm running meteor 1.10.1

Gregivy commented 4 years ago

The error comes from the server, it seems the server did not throw an error but for some reason denied the subscription.

hems commented 4 years ago

The error comes from the server, it seems the server did not throw an error but for some reason denied the subscription.

My application was doing the follow during start:

I suspect the problem happened when I was trying to stop a subscription while logged out or concurrently subscribing and unsubscribing to the same sub.

I worked around that issue by only trying to subscribe if I have an userId.

Still, I believe since we discovered that it's possible to have a message without the .error I believe it would be good to check for that property and throw it only if exists?

That problem actually blocked other parts of my application that were using simpleDDP, that might have been because of the way my application works but might as well be because simpleDDP got in a weird state?