Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript heap out of memory on version 6.3.4 #11823

Closed
the-nance opened this issue May 21, 2022 · 6 comments
Closed

JavaScript heap out of memory on version 6.3.4 #11823

the-nance opened this issue May 21, 2022 · 6 comments
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. Stale

Comments

@the-nance
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
I keep getting FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory when i use findOneAndUpdate

If the current behavior is a bug, please provide the steps to reproduce.

This is my settings schema:

{
  id: String,
  registered_at: {
    type: Number,
    default: Date.now()
  },
  registered_by: Number,
  action: String,
  min_ag: {
    type: Number,
    default: 259200000
  },
  unv_r: Number,
  log_c: Number,
  men_r: Number,
  ver_r: Number,
  mod_r: Number
}

upon executing the following query, it runs out of memory

settingsSchema.findOneAndUpdate({
    id: "410488579140354049"
}, data, {
    new: true,
    upsert: true
})

What is the expected behavior?
Upon executing that, the process should be complete and it should be saved.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
mongoose: v6.3.4
mongoDB: v4.6.0
node: v16.13.2

@the-nance
Copy link
Author

I came across a similar issue that occured about a year ago #9864

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 21, 2022

We need a mvce to investigate further.

@AbdelrahmanHafez
Copy link
Collaborator

AbdelrahmanHafez commented May 23, 2022

For more info on what we mean by that: https://stackoverflow.com/help/minimal-reproducible-example

A good example for a repro script would be #11138 (comment)

@IslandRhythms IslandRhythms added needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. and removed needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue labels May 25, 2022
@IslandRhythms
Copy link
Collaborator

modify the script to demonstrate your issue

const mongoose = require('mongoose');

const testSchema = new mongoose.Schema({
    id: String,
  registered_at: {
    type: Number,
    default: Date.now()
  },
  registered_by: Number,
  action: String,
  min_ag: {
    type: Number,
    default: 259200000
  },
  unv_r: Number,
  log_c: Number,
  men_r: Number,
  ver_r: Number,
  mod_r: Number
});

const Test = mongoose.model('Test', testSchema);

async function run() {
    await mongoose.connect('mongodb://localhost:27017');
    await mongoose.connection.dropDatabase();

    await Test.create({
        id: '410488579140354049',
        registered_by: 12345,
        action: 'Action',
        unv_r: 1,
        log_c: 2,
        men_r: 3,
        ver_r: 4,
        mod_r: 5
    });

    let data = {unv_r: 10, log_c: 11, men_r: 12, ver_r: 13, mod_r: 14}

    await Test.findOneAndUpdate({ id: "410488579140354049"}, data, {new: true, upsert: true} );
    console.log('done');
}

run();

@github-actions
Copy link

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Jun 10, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 19 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. Stale
Projects
None yet
Development

No branches or pull requests

4 participants