Skip to content

Unable to set cursor timeout on Mongoose Schema.find().stream() #3354

@debanjanbasu

Description

@debanjanbasu
{ [MongoError: cursor killed or timed out] name: 'MongoError', message: 'cursor killed or timed out' }

I am using the following code to poll the google docs API. I am polling with around 6k requests so the stream needs to be open for more than 10 minutes (default). I've tried with all the suggested online methods in vain.

Here is the code and please guide me on how to achieve this simple feat.

                // create a mongoose stream
                let orderstream = Order.find().stream();
                // start listening to events on the stream
                orderstream.on('data', (doc) => {
                    // check if data already exists

                    // add some data
                    addRow(orderstream, sheet1, doc, 0);

                }).on('error', (err) => {
                    console.log(err);
                    // send success
                    // res.json({
                    //     'status': 'failure'
                    // });
                }).on('close', () => {
                    // the stream is closed
                });

Don't give me the option to use nodejs-native mongodb driver. It works... But I don't wanna include another additional module to achieve what might be possible to be done using mongoose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    helpThis issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions