mongo icon indicating copy to clipboard operation
mongo copied to clipboard

fix: reject promise if deserializeMessage throws

Open williamhorning opened this issue 1 year ago • 7 comments
trafficstars

if deserializeMessage throws for any reason (such as a BSONError), the pendingMessage promise will never resolve. this PR changes this behavior so that the promise will reject if there's an error thrown

williamhorning avatar May 16 '24 01:05 williamhorning

Is this testable? Would be nice to have one bad path test where it gets rejected 😅

Thanks anyway and if you don't find the time i can merge it

lucsoft avatar May 16 '24 07:05 lucsoft

Is this testable? Would be nice to have one bad path test where it gets rejected 😅

Thanks anyway and if you don't find the time i can merge it

I could try to take a look at this later today but in theory it shouldn't be too difficult (get some bad BSON data to cause an issue)

williamhorning avatar May 16 '24 13:05 williamhorning

@lucsoft it doesn't seem like there's an easy way to force MongoDB to return invalid bson so unless you know of a way to do that, I don't really know how I'd write a test for this

williamhorning avatar May 18 '24 18:05 williamhorning

@williamhorning well the only way would be to edit the raw bson like flipping a bit or something

lucsoft avatar May 18 '24 18:05 lucsoft

@lucsoft i don't really see a way of reliably doing that with the current CI setup. additionally, most people will probably never run into bson errors unless they're doing something weird or if there's a bug with mongodb

williamhorning avatar May 18 '24 18:05 williamhorning

@williamhorning okay then I just merge it

lucsoft avatar May 18 '24 18:05 lucsoft

Just fix CI and then I merge it

lucsoft avatar May 18 '24 18:05 lucsoft

@lucsoft i fixed CI

williamhorning avatar May 19 '24 01:05 williamhorning