Intermittent weird bug CosmosDB / Mongo

I run CosmosDB and get a strange intermittent error when I try to find the user and update his information.

My challenge:

bcrypt.hash(newpassword, salt, null, (err, hash) =>
            {
                if (err) { return next(err); }

                User.findByIdAndUpdate(user.id, { password: hash, resetPassword: {} }, (err) =>
                {
                    if (err) { return next(err); }

                    const { email } = user;

                    res.json({ email, token: tokenForUser(user) });
                });
            });

Error:

> MongoError: Message: {"Errors":["The requested operation cannot be
> performed at this region"]} ActivityId:
> 0ff0db7f-0000-0000-0000-000000000000, Request URI:
> /apps/7ef8ebd7-3aa2-4da3-bbc0-23dd39025348/services/5b9e0c68-6a68-4fae-a9f1-f968d368a9a7/partitions/34a98539-b29b-4f4d-86c8-dd96141721a4/replicas/131495233632205703p/
>     at Function.MongoError.create (C:\Users\BaruchKogan\Documents\Visual Studio
> 2017\Projects\TrellisAuth\node_modules\mongodb-core\lib\error.js:31:11)
>     at C:\Users\BaruchKogan\Documents\Visual Studio 2017\Projects\TrellisAuth\node_modules\mongodb-core\lib\connection\pool.js:497:72
>     at authenticateStragglers (C:\Users\BaruchKogan\Documents\Visual Studio
> 2017\Projects\TrellisAuth\node_modules\mongodb-core\lib\connection\pool.js:443:16)
>     at Connection.messageHandler (C:\Users\BaruchKogan\Documents\Visual Studio
> 2017\Projects\TrellisAuth\node_modules\mongodb-core\lib\connection\pool.js:477:5)
>     at TLSSocket.<anonymous> (C:\Users\BaruchKogan\Documents\Visual Studio
> 2017\Projects\TrellisAuth\node_modules\mongodb-core\lib\connection\connection.js:331:22)
>     at emitOne (events.js:96:13)
>     at TLSSocket.emit (events.js:188:7)
>     at readableAddChunk (_stream_readable.js:176:18)
>     at TLSSocket.Readable.push (_stream_readable.js:134:10)
>     at TLSWrap.onread (net.js:547:20)

Any ideas what this means or how to fix them?

+4
source share

Source: https://habr.com/ru/post/1688142/


All Articles